![](https://davidstockdalescrapcode.co.uk/wp-content/uploads/2021/07/sound.jpg)
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”.
![](https://davidstockdalescrapcode.co.uk/wp-content/uploads/2024/04/gsheet-apps-script-1.jpg)
This will open a new Apps Script project connected to this spreadsheet.
![](https://davidstockdalescrapcode.co.uk/wp-content/uploads/2024/04/gsheet-apps-script-2.jpg)
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()