Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Reference cell from another document

Is it possible to have a cell in one document reference a cell in another.


There are several instances where I'd like to do this, but one example would be to have the monthly income cell in my budget document change when the average of all my paychecks YTD change in my paycheck document.

Posted on Feb 26, 2017 6:02 PM

Reply
24 replies

Mar 1, 2017 6:56 PM in response to SGIII

My original question:


"Is it possible to have a cell in one document reference a cell in another.


There are several instances where I'd like to do this, but one example would be to have the monthly income cell in my budget document change when the average of all my paychecks YTD change in my paycheck document."


Can I have B11 from the work document be displayed in B2 of the budget document?


This may be a little more complicated but what about creating the formula used in B11 of the work document in B2 of the budget document?

=AVERAGE(column B from work document)x4



User uploaded file


You said it's possible to reference another Numbers document via AppleScript or JavaScript for Automation (JAX).


Would you mind explaining how?

Mar 2, 2017 6:02 AM in response to The Tech Nut

Tech,


I suggest trying to keep all the data in the same document (which is stored on your hard drive as a file).


User uploaded file


In a Numbers document (show in screenshot above and titled "Untitled 37") there are several sheets (named "Summary", "Sheet 1", "Sheet 2", etc)


"Sheet 5" has a table that contains cells


You can store your data on one sheet and process/summarize the data in what ever way you want in other (or the same) sheet(s)


I suggest having a Numbers document for your budget that has a sheet for income, another for expenses and a summary.


This will remove the requirement to access another document

Mar 3, 2017 7:17 PM in response to The Tech Nut

TheTechNut wrote:


Let's say I want to have the information in Document 1, Sheet 1, Table 1, Cell A2 added to Document 2, Sheet 1, Table 1, Cell A2. I


The AppleScript could be this:


tell application "Numbers"

set srcCell to document "MyTestDoc1.numbers"'s sheet 1's table 1's cell "A2"

set tgtCell to document "MyTestDoc2.numbers"'s sheet 1's table 1's cell "A2"

set tgtCell'svalue to (tgtCell'svalue) + (srcCell'svalue)

end tell


And the JavaScript for Automation could be this:


Numbers = Application('Numbers');

var srcCell = Numbers.documents['MyTestDoc1.numbers'].sheets[0].tables[0].cells['A2'];

var tgtCell = Numbers.documents['MyTestDoc2.numbers'].sheets[0].tables[0].cells['A2'];

tgtCell.value = tgtCell.value()+srcCell.value();



In both cases you copy-paste the script into Script Editor (in Applications > Utilities) make sure Script Editor is checked at System Preferences > Security & Privacy > Privacy > Accessibility (this only needs to be done once) and also is toggled to the right scripting language, make sure both Numbers documents are open, and click the 'triangle' run button in Script Editor. If you end up with a script that you use often there are ways to have it in your menu and also attach it to a keyboard shortcut. Scripts can be an easy way to extend the functionality of Numbers, but note that they don't trigger updates automatically the way formulas do. You must trigger them yourself.


SG

Feb 26, 2017 6:22 PM in response to The Tech Nut

"Is it possible to have a cell in one document reference a cell in another."


If the referencing document is a Numbers document, no.


Numbers cannot reference external documents other than to:

  • Open a page on the web
  • Open a new message in Mail, ready to be composed and sent.


AppleScript, or an Automator Service using an AppleScript may be able to open a separate document, collect a value from a specific location in that document, and place that value in a specific location in a Numbers document. If it is possible, the action would require user action to trigger. Details and confirmation would have to come from a source more familiar with AppleScript and what it can do, though.


Regards,

Barry

Feb 26, 2017 6:34 PM in response to The Tech Nut

Yes, it's possible to reference another Numbers document via AppleScript or JavaScript for Automation (JAX).


But why go to that trouble when you can just keep your work within one document? A document can have a number of sheets, and each sheet can have multiple tables. That should be more than enough to work with.


SG

Mar 1, 2017 5:54 PM in response to SGIII

SG,


Can you explain how to do it?


If it is too difficult I will continue to manually update it each month.


I can't keep everything in one document b/c besides that one bit of information the documents have nothing to do with each other. One is for work to track my pay, acquired vacation/personal time and other work related information. The other is for my personal finances which tracks & categorizes every penny I spend, save and earn to create a monthly budget. It's already a complex document with multiple tables/sheets and as I stated, there are several instances where this could be useful to me. I have documents for a variety of things that may use one piece of information from a different document and it would be nice if I didn't have to update those fields manually every time that information changes.

Mar 1, 2017 7:47 PM in response to The Tech Nut

Numbers has documents, and documents have sheets, and sheets have tables, and tables have cells.


Scripts require precise terminology. To have a working example, you would need to start with providing that.


You mention that you want a cell in one document to change when an average changes in another document. That's not how scripts generally work. A script is not triggered by a change in a value in a cell. You have to trigger a script yourself.


SG

Mar 3, 2017 3:30 PM in response to SGIII

SGIII,


You may have noticed I am a novice with this stuff. So I don't know the precise terminology you're asking for. Which is why I was asking if you could explain it. You could use any 2 documents as an example and I'm sure I could reverse engineer it to use in my own documents.


Let's say I want to have the information in Document 1, Sheet 1, Table 1, Cell A2 added to Document 2, Sheet 1, Table 1, Cell A2. If that terminology isn't specific enough then I don't know what you're asking for.


I'm not going to upload screenshots and specifics of my actual documents to the internet b/c they have my personal/financial information in them. I figured based on everything I have already provided you'd have enough to give me an example of how it works.

Mar 3, 2017 6:45 PM in response to The Tech Nut

Maybe you need to do a restart to get the System Preferences settings to "take."


Or, I've noticed the .numbers extension doesn't show in your screenshot the way it does on my setup. You could try removing the .numbers from the script and see if that works on your setup. Or in Finder > Finder Preferences > Advanced try enabling 'Show all filename extensions.'


SG

Reference cell from another document

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.