Get sheet name and sheet id

Here is how to get sheet name and sheet id.


Source Code

function myFunction(){
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Get Active spreadsheet object
  var sh = spreadsheet.getActiveSheet(); // Get Active sheet's object
  var shName = sh.getSheetName();
  var shId = sh.getSheetId();
  
  Browser.msgBox("Sheet Name:" + shName + " / Sheet ID:" + shId);
}


Format

(1) Get Sheet Name

SheetObject.getSheetName()

(2) Get Sheet ID

SheetObject.getSheetID()


What is sheet id?

You can see the sheet id in the end of the spreadsheet URL.

4 thoughts on “Get sheet name and sheet id”

Leave a Comment