
The Google Sheets formula `INDIRECT` is a game-changer for getting a sheet by name.
With `INDIRECT`, you can use a cell reference to a sheet name, making it easy to dynamically switch between sheets.
You can also use the `GET.SHEET` function, which is a more straightforward way to get a sheet by name.
Working with Sheets
To get the current sheet name in Google Sheets, you can use a custom script. This is especially useful in dashboards or reports where the sheet name is used as a reference.
The script can be created by clicking Tools > Script editor in Google Sheets, which opens the Apps Script editor.
You can then copy and paste a script code into the editor to create a custom function to return the current sheet name.
Get Names List
Getting a list of all sheet names in Google Sheets can be a bit tricky, but don't worry, I've got you covered. You can use a custom app script formula to get the active sheet name, and even list all the sheet names in your workbook.
Discover more: Dependent Drop down List in Google Spreadsheet
To get all sheet names, you can use a For loop to circle through all the worksheets in the Google Sheets document. This will start listing the sheet names in the cell where you entered the formula, one cell down with each sheet name.
For this formula to work, you need to have all the empty cells that would be filled by the formula result. If you have 10 worksheets in the document, using this formula is going to occupy 10 cells starting from the cell where you entered the formula.
You can also create a custom function through Apps Script to retrieve the names of all sheets within the same Google Sheets file. This can be useful for building an index, summary dashboard, or table of contents.
To do this, you'll need to click Tools > Script editor, copy and paste the provided script code, and save the script. Then, go back to your spreadsheet and enter the formula =sheetnames() in the cell where you want the list of all sheet names to appear.
If you receive permission prompts, follow them to authorize the script. If no names are listed, double-check that the function name in the Apps Script file and in the cell formula match sheetnames exactly.
Here's a quick summary of the steps to get all sheet names:
- Open the Script editor by selecting Tools > Script editor
- Copy and paste the provided script code
- Save the script
- Enter the formula =sheetnames() in the cell where you want the list of all sheet names to appear
Get Current Name
You can display the name of the currently active sheet in Google Sheets without manually entering it. This is especially useful in dashboards, reports, or templates where the sheet name is used as a reference or in headers for easy identification.
To do this, you'll need to create a custom script in the Apps Script editor. This can be accessed by clicking Tools > Script editor in your Google Sheets workbook.
In the script editor, you can paste a simple script code that creates a custom function to return the current sheet name. After saving the script, you can enter the formula =sheetname() in your chosen cell, and the current sheet name will be shown immediately.
To troubleshoot any issues, ensure that the script was saved correctly, and the function name matches the one used in your formula. If you copy the spreadsheet or script, you may need to reauthorize permissions.
You might like: Google Spreadsheet Match Function
Here's a simple script code that you can use to get the current sheet name:
function GetCurrentSheet() {
return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}
You can enter this code into the script editor by deleting any existing code and replacing it with this custom code. Then, you can enter the formula =GetCurrentSheet() in your spreadsheet to call the custom function that will get the sheet name.
Alternatively, you can use a custom function to return the current sheet name. To do this, you'll need to paste a script code into the Apps Script editor and save it. Then, you can enter the formula =sheetname() in your chosen cell to display the current sheet name.
Note that the displayed sheet name is updated when the sheet is recalculated.
A fresh viewpoint: Google Spreadsheet Copy Value Not Formula
Featured Images: pexels.com


