I just started using applescript last week and I’m stuck and need some help. This is a simple script that currently moves a range of formulas (k5:s16) to the bottom of a table. This is what I have so far:
tell application “Microsoft Excel”
set lastFilledCell to (get end (range “b5:j1000” of worksheet “AD Orders”) direction toward the bottom)
set firstBlankCell to (get offset lastFilledCell row offset 1)
copy range (range “k5:s16”) destination firstBlankCell
end tell
The above script works but I now want the range of formulas (k5:s16) to be placed within the table starting on the first row where the first cell in column c is equal to 0. Note that the table runs from b5 to j1000. (Much of this is empty and the table will populate over time via another script I have).
Thank you in advance for any assistance you can provide.
Unfortunately all the machines here are running Excel 2008. I’ve got PCs at home and can get VBA to do this but the code doesn’t seem to be compatible with the Excel 2008 macro feature. I’ll see if I can locate someone running 2011. Many thanks for the post!
tell application "Microsoft Excel"
set firstNewRow to first row index of range "FirstZeroInC"
set formulaRange to range "K5:S16"
set newRange to cell firstNewRow of range "K:K"
set newRange to get resize newRange row size (count of rows of formulaRange) column size (count of columns of formulaRange)
set formula r1c1 of newRange to get (formula r1c1 of formulaRange)
end tell
Yes spelling was the cause of the error - sorry about that. When typing =FirstZeroInC+2 this does return a 2.
I re-ran the script. It did not copy the formulas (k5:s16) over to the bottom of the table (B:J), beginning in the row where c was = to 0. Instead the script copied the first row of formulas (k5:s5) down 6 rows to k6:s11. The formulas that were originally in rows k6:s11 then followed. The formulas that were in k12:s16 disappeared.