1
sheetFunction {
  var sourceFile   = SpreadsheetApp.openById("1asdasdasdasdasd");

  // Set sheet
  var masterSheet  = sourceFile.getSheetByName("Master");
  masterSheet.activate
}

cellFunction {
  var sourceFile   = SpreadsheetApp.openById("1asdasdasdasdasd");

  // Set sheet
  var masterSheet  = sourceFile.getSheetByName("Master");
  masterSheet.getRange("A1").activate
}

I'm starting out on google scripts and trying to create some simple functions. Was referring to some functions over the net. What does the activate mean in the 1sheetFunction and what is the difference with cellFunction?

1
1

As mentioned in the example at the official site:

Sets the active sheet in a spreadsheet, with the option to restore the most recent selection within that sheet. The Google Sheets UI displays the chosen sheet unless the sheet belongs to a different spreadsheet.

// Set the first sheet as the active sheet and select the range D4:F4. spreadsheet.setActiveSheet(firstSheet).getRange('D4:F4').activate();

Please read more about it at: setActiveSheet(sheet, restoreSelection)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.