The setting value in the cell in the spreadsheet to which the script is attached
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME).getRange(RANGE).setValue(VALUE);
The value of the setting in the cell in the sheet that is currently open and to which the script is attached
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(RANGE).setValue(VALUE);
The value of the parameter in the cell in any spreadsheet that the script is not connected to (name of the target sheet name)
SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME).getRange(RANGE).setValue(VALUE);
The value of the parameter in the cell in any spreadsheet to which the script is NOT connected (the position of the destination location is known)
SpreadsheetApp.openById(SHEET_ID).getSheets()[POSITION].getRange(RANGE).setValue(VALUE);
These are constants, you must define them yourself
SHEET_ID SHEET_NAME POSITION VALUE RANGE
By a script attached to a sheet, I mean that the script is in the script editor of this sheet. Not attached means that it is not in the script editor of this sheet. It can be anywhere else.
Umair Dec 20 '17 at 8:06 2017-12-20 08:06
source share