Simple counting loop

I want to find how many rows are being used in a Number spreadsheet. I have a script for Excel which includes

set numRows to name of first row  of (find cell of range "A:A" what "")

I seem to have to count ‘manually’ with Numbers, so it must be an easy bit of AppleScript to test each cell in a column and see if its empty, then report the number of tests made (the number of rows).

Numbers doesn’t appear to have empty cells so I’m assuming I need to find the first cell in a column which contains “0.0”.

tell application "Numbers"
	tell table 1 of sheet 1 of document 1
		repeat with n from 1 to row count
			if value of cell 1 of row n of column 1 is "0.0" then
				return n
			end if
		end repeat
	end tell
end tell

I can see the script get the value of the cells, the first dozen and not “0.0”, but it carries on because I’ve not worked out how to stop the script at the first blank cell.

Sorry its a basic question which I should really know…

Thanks!

Hi.

The value of an empty cell in Numbers is the real value 0.0, not the text value “0.0”.

You could use a filter to find the row number you want, which would save using a loop:

tell application "Numbers"
	tell table 1 of sheet 1 of document 1
		set n to address of row of first cell of column 1 whose value is 0.0
	end tell
end tell

Hi,

you are comparing a string “0.0” with a number 0.0 which is never equal


.
if value of cell 1 of row n of column 1 is 0.0 then
.

This should do the same thing


tell application "Numbers"
	tell table 1 of sheet 1 of document 1
		set firstUnusedCell to name of 1st cell of column 1 whose value is 0.0
	end tell
end tell

Thank you both.

The two examples work but I will use Nigel’s as it gives me a count (just the row number) whereas StefanK’s is the actual cell address. But that may come in useful later!

Thanks again.

DG