I have been trying to find a way to increment by +1 the last available cell in an excel spreadsheet without any success.

I can locate the last empty cell in my range but cannot find the syntax to get the last cell value and increment it by +1?

Can anyone point out a syntax to do so?

Here is what I have for finding the last empty cell and trying to increment it!

tell application "Microsoft Excel"
tell active sheet
set usedRange to used range
set firstUnusedRow to row ((count rows of usedRange) + 1)
set nextUnusedRow to (value of usedRange) + 1
end tell
end tell

tell application "Microsoft Excel"
tell active sheet
set usedRange to used range
set lastUsedRow to row (count rows of usedRange)
set lastUsedRowValue to (value of column 1 of lastUsedRow as integer) + 1
end tell
end tell

How can I add leading 000 in front of the incremented value? Now if the last cell value is “5” then the script gives me “6” but actually I would like it to return “0006”?

Hey Stefan I found a solution that is working what do you think about it?

tell application "Microsoft Excel"
tell active sheet
set usedRange to used range
set lastUsedRow to row (count rows of usedRange)
set lastUsedRowValue to (value of column 1 of lastUsedRow as integer) + 1
set n to lastUsedRowValue
set padded_number to text -4 thru -1 of ("0000" & n)
end tell
end tell