I have 2 Google sheets:
- Source Sheet
- Target Sheet
The source sheet needs to update the values in the Target Sheet.
For example if we consider the below data:
Color | Size | QTY | Cost |
---|---|---|---|
Black | Large | 2 | $100.00 |
Black | Small | 1 | $50.00 |
Red | Small | 5 | $250.00 |
What I am trying to achieve is writing a google script that will basically "push" data from the "Source Sheet" to the "Target Sheet"
Critical to Understand:
"Target Sheet" would contain the exact same fields / structure, so we need to identify the updated rows and only update those with the new updated information from the "Source Sheet"). If you think in terms of SQL this would be something like a UPDATE {fields} WHERE...
type of statement.
A few questions / comments:
- When executing the script in the "Target Sheet" - will I need to delete the affected rows first and then append them? or,
- Is there a method where you can directly update the values of the affected rows (similar to
SQL UPDATE
?
I would like to utilise the methods contained in Sheets API v4, eg:
Update:
- This questions is not answered by the below existing discussion on Stack Overflow:
Google Apps Script, copy one spreadsheet to another spreadsheet with formatting
Reasons: The above question talks about copyng an entire sheet / range from one sheet to another, where as this question is related to UPDATING Information from one sheet to another
- I am not suggesting a realtime link between the documents (ie. using importrange, I am actually wanting to write / paste updated data from one sheet to another