How to make a button to jump to a specific cell in another sheet in Google Spreadsheet?

20,612

You can't have the cell reference in the sheet name. You have to send them as separate variables.

function goToSheet2b() {
  // 1 = row 1, 14 = column 14 = N
  goToSheet("8601-10", 1, 14);
}

function goToSheet(sheetName, row, col) {
  var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
  SpreadsheetApp.setActiveSheet(sheet);
  var range = sheet.getRange(row, col)
  SpreadsheetApp.setActiveRange(range);
}
Share:
20,612
Admin
Author by

Admin

Updated on February 25, 2020

Comments

  • Admin
    Admin about 4 years

    I have a Google spreadsheet with many sheets and a table of contents. Is there some way to create a button in the main sheet so that with a click one can go directly to the cell in another sheet?

    I figured out the way to make button and assigned the script to the button.

    I modified a script to become like this, but I have problem on the last line, what should I do?

    function goToSheet2b() {
      goToSheet("8601-10!N1");
    }
    
    function goToSheet(sheetName) {
      var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
      SpreadsheetApp.setActiveSheet(sheet);
    }
    

    PS: 8601-10 is the name of the other sheet I need to go to.

    Thank you for your help.