smrc8081 wrote:
I am under the impression the only way between AppleScript and Numbers is to stuff cells one at a time.
Yes, natively, AppleScript is inefficient at setting values of a large number of cells in Numbers (unlike, I believe, in Excel).
However, GUI-scripting can do the job nicely.
Try this script, which copies and pastes through the clipboard:
copyIt("Sheet 1", "Table 1", "A2:D6")
pasteIt("Sheet 1", "Table 2", "A2:D6")
to copyIt(shtName, tblName, rngName)
tell application "Numbers"
tell document 1
tell table tblName of sheet shtName
set selection range to range rngName
tell application "Numbers" to activate
tell application "System Events" to keystroke "c" using command down
end tell
end tell
end tell
end copyIt
to pasteIt(shtName, tblName, rngName)
tell application "Numbers"
delay 0.1 -- may need to vary this
tell document 1
tell table tblName of sheet shtName
set selection range to range rngName
tell application "Numbers" to activate
tell application "System Events" to keystroke "v" using command down
end tell
end tell
end tell
end pasteIt
I tested it on tables on Sheet 1 that look like these:
Both values and formulas copy as expected.
Just change the references within copyIt and pasteIt to suit your needs. For example to copy a formula from F2 to F3:F434 you would do something like this:
copyIt("Sheet 1", "Table 1", "F2")
pasteIt("Sheet 1", "Table 1", "F3:F434")
(don't modify the rest of the script when you change the ranges, etc. in the first two lines)
To allow the paste you may need to go to System Settings > Privacy & Security > Accessibility and add the application you are using to the list of applications allowed to control your computer. I added Script Editor because I ran the script from there. You may need to add Script Debugger, or whatever you are using.
SG