Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data binding in google spreadsheet?

Is it possible to write a google apps script that "binds" two cells together? For example, if a a cell in one sheet is edited, it will automatically update a matching cell in another sheet.

So if sheet1 had a value representing "money spent" in cell A1, and sheet2 had a value representing the same "money spent" in cell B4, I'd want to be able to change the value in sheet2.B4 or sheet1.A1, and both of the cells will always be up to date.

I'm having trouble determining how to create a trigger that could perform this.

like image 756
johncorser Avatar asked Jul 15 '14 20:07

johncorser


People also ask

How do you bind a script in Google Sheets?

To create a bound script in Google Docs, Sheets, or Slides, open a document in Docs, a spreadsheet in Sheets, or a presentation in Slides and click Extensions > Apps Script. To reopen the script in the future, do the same thing or open the script from the Apps Script dashboard.

Does Google Sheets have a data model?

Creating a Data Model This is the step where you add in your Google spreadsheet database. To do this, click on “Data Modelling” in the header and then click on “+Create Data Model” on top right and select “Data Import”.

How do I trace a dependent in Google Sheets?

Click on a formula within your spreadsheet, click the Find Precedents or Find Dependents button, and immediately see every formula, cell, named range, and element that goes into making up the number you see on your screen.


1 Answers

You can create a trigger that runs a function when a cell in the Sheet is edited:

SpreadsheetTriggerBuilder onEdit()

Then the script would need to find the cell that was edited, get the value, and put the value into the new cell.

You could use getRange():

getRange(row, column) of the Sheet Class

See this question also:

StackOverflow get and set

like image 162
Alan Wells Avatar answered Nov 15 '22 00:11

Alan Wells