0

I have a script set that unhides a page and selects a cell for editing. However, I notice that when the script runs, I have to "select" (click on) the cell again to allow for data to be written to that cell. Is there a better way than the code I have set running as seen below?

function class1() {
  var spreadsheet = SpreadsheetApp.getActive(); 
  spreadsheet.getRange('A1').activate(); 
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Class 1'), true); 
  spreadsheet.getRange('A2').activate();
}

I want it to automatically allow data to be entered in A2 once the script has finished running but it seems to always stop that till I click on it and manually "activate" the cell.

1 Answer 1

1

The Range.activate() method lets you select a cell, but it does not open the cell for editing. When a cell is selected, you can start typing to overwrite old contents in the cell, or press Enter to open the cell and edit its existing contents.

Your scriptlet can be shorted like this:

function class1() {
  SpreadsheetApp.getActive().getRange('Class 1!A2').activate();
}

See Apps Script at Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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