Google Sheets doesn’t provide a built-in formula like =SHEETNAME()
to return the name of the current sheet — and common workarounds like CELL("address", A1)
no longer work reliably.
In this article, we’ll show you the correct and reliable way to get the current sheet name using Google Apps Script. We’ll also cover how to safely use that sheet name in URLs or API calls.
❌ Why CELL("address", A1)
Doesn’t Work
A widely shared formula is:
=CELL("address", A1)
This used to return 'SheetName'!A1
in some tools like Excel. But in Google Sheets, it only returns:
$A$1
— just the cell address, no sheet name. So it’s not helpful for dynamically getting the current sheet.
✅ The Reliable Way: Use a Simple Apps Script Function
The most accurate and stable method is to use a small custom function in Google Apps Script.
Step-by-step:
- In your sheet, go to Extensions → Apps Script
- Delete any placeholder code and paste this:
function MY_BIZ_SHEET_NAME
() {
return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}
- Click Save or press CMD+S [Mac] or CTRL+S to save [Windows & Linux]
- Close the Apps Script editor
- In any cell of your sheet, type:
=MY_BIZ_SHEET_NAME
()
✅ That’s it! This will now return the name of the current sheet, no matter what characters it contains — spaces, dashes, emojis, etc.
It is important to put a prefix to the function so you and your colleagues know that it's a custom function and not a standard one.
🔧 Bonus: Use the Sheet Name in a URL Safely (Encode It)
If you plan to use the sheet name inside a formula like IMPORTDATA
, it’s best to URL-encode it. Google Sheets doesn't have a native ENCODEURL()
function — but you can add one:
Add a custom ENCODEURL
function
- In the same Apps Script editor, add this too:
function MY_BIZ_ENCODE_URL(input) {
return encodeURIComponent(input);
}
- Save again
- Now you can use it like this:
=IMPORTDATA("https://example.com/data?sheet=" & MY_BIZ_ENCODE_URL
(MY_BIZ_SHEET_NAME
()))
This ensures the URL is safe even if your sheet name includes:
- Spaces (
%20
) - Symbols like
#
,&
,/
- Unicode characters or accented letters
The scripts should look like this

📌 Use Cases
Here’s where this comes in handy:
- Auto-labeling reports based on the sheet name
- Dynamically building API URLs
- Debugging dashboards or templates
- Displaying the current sheet name in a header or title cell
- Loading data based on the sheet name which can be date specific e.g. Report-2025-01 and the backend can parse that report_id and extract the date from it pretty easily.
✅ Summary
Method | Dynamic? | Safe? | Requires Script? | Notes |
---|---|---|---|---|
= (Apps Script) | ✅ | ✅ | ✅ | Best method |
| ✅ | ✅ | ✅ | For use in URLs |
Manual entry | ❌ | ✅ | ❌ | For small use cases only |
🚀 Final Thoughts
Until Google introduces an official =SHEETNAME()
function, this Apps Script-based approach is the cleanest, most reliable way to get the current sheet name in Google Sheets — and use it safely across your formulas.
This link gave us the idea for https://stackoverflow.com/questions/45502538/is-there-a-google-sheets-formula-to-put-the-name-of-the-sheet-into-a-cell for the article.