Reputation: 25
Looking to run a script on spreadsheet A and change values on spreadsheet B. If I was running the script within spreadsheet B the following works:
function clear() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('Responses!C8:E50').setValue('');
}
How do I change the above script to do the same on a different spreadsheet?
Thanks in advance - Paul
Upvotes: 1
Views: 65
Reputation: 2699
You can use openbyID
to change data on other sheet from your current sheet, the ID here is refer to the unique combination of text & number from the sheet URL:
function clear() {
var spreadsheet = SpreadsheetApp.openById('xxxxxx')
spreadsheet.getRange('Responses!C8:E50').setValue('');
}
Upvotes: 1