Data binding in google spreadsheet?

2019-05-10 21:30发布

问题:

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.

回答1:

You can create a trigger for when a sheet is edited:

SpreadsheetTriggerBuilder onEdit()

Then the script would need to find the cell that got 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