Numbers
Can I automatically populate. a cell in a spreadsheet from a cell in another spreadsheet?
You can make a difference in the Apple Support Community!
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
Can I automatically populate. a cell in a spreadsheet from a cell in another spreadsheet?
Yes. Scripts can be fiddly. But so can formulas.
Here's a basic AppleScript to get you started if you really need to do this. Fill in particulars of your set up in first lines.
property src1 : {doc:"Source1.numbers", sht:"Sheet 1", tbl:"Table 1", rng:"A2:B4"}
property tgt1 : {doc:"Target.numbers", sht:"Sheet 1", tbl:"Consolidated", rng:"A2:B4"}
property src2 : {doc:"Source2.numbers", sht:"Sheet 1", tbl:"Table 1", rng:"A2:B4"}
property tgt2 : {doc:"Target.numbers", sht:"Sheet 1", tbl:"Consolidated", rng:"A5:B7"}
copyVals(src1, tgt1)
copyVals(src2, tgt2)
to copyVals(src, tgt)
tell application "Numbers"
try
--read values in source range into AppleScript list
tell document (src's doc)
tell sheet (src's sht)
tell table (src's tbl)
tell range (src's rng)
set vv to cells's value
end tell
end tell
end tell
end tell
--write values from list to target range
tell document (tgt's doc)
tell sheet (tgt's sht)
tell table (tgt's tbl)
tell range (tgt's rng)
repeat with i from 1 to count cells
set cell i's value to vv's item i
end repeat
end tell
end tell
end tell
end tell
on error
display alert "Check addresses, ranges, and size of destination table" buttons "Ok"
end try
end tell
end copyVals
SG
Yes. Scripts can be fiddly. But so can formulas.
Here's a basic AppleScript to get you started if you really need to do this. Fill in particulars of your set up in first lines.
property src1 : {doc:"Source1.numbers", sht:"Sheet 1", tbl:"Table 1", rng:"A2:B4"}
property tgt1 : {doc:"Target.numbers", sht:"Sheet 1", tbl:"Consolidated", rng:"A2:B4"}
property src2 : {doc:"Source2.numbers", sht:"Sheet 1", tbl:"Table 1", rng:"A2:B4"}
property tgt2 : {doc:"Target.numbers", sht:"Sheet 1", tbl:"Consolidated", rng:"A5:B7"}
copyVals(src1, tgt1)
copyVals(src2, tgt2)
to copyVals(src, tgt)
tell application "Numbers"
try
--read values in source range into AppleScript list
tell document (src's doc)
tell sheet (src's sht)
tell table (src's tbl)
tell range (src's rng)
set vv to cells's value
end tell
end tell
end tell
end tell
--write values from list to target range
tell document (tgt's doc)
tell sheet (tgt's sht)
tell table (tgt's tbl)
tell range (tgt's rng)
repeat with i from 1 to count cells
set cell i's value to vv's item i
end repeat
end tell
end tell
end tell
end tell
on error
display alert "Check addresses, ranges, and size of destination table" buttons "Ok"
end try
end tell
end copyVals
SG
A (slightly) off topic note to SGIII:
Came across a current post with a Pages issue that looks like a solution would require a script. Could you take a look at How to find duplicate paragraphs in a document, in the Pages for Mac community?
Regards,
Barry
It depends on what you mean by "spreadsheet". If you mean a cell in a different document then no. If you mean a cell in a different table within the same document then yes.
Thanks for your reply but I was referring to a different Numbers document. So it would appear that this is not possible.
It is possible via script but not via formula.
SG
Thanks SG, it would appear that I need to learn how to write a script if I want to do this.
Numbers