David Stockdale's Scrapcode

Get Sheet Name in Google Sheets Function

A simple bit of Google Apps Script that can be placed onto any Google Sheet to add a function which returns the name of whatever sheet it’s placed within.

First in your spreadsheet click “Extensions” and open “Apps Script”.

This will open a new Apps Script project connected to this spreadsheet.

Now input this code and save the project.

/** 
 * ================================= Sheet Name =================================
 */
function sheetName() {
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}

Now you can simply use the function below to in any cell to automatically get the name of the sheet that cell is within:

=sheetName()

Leave a Reply