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:

  1. In your sheet, go to Extensions → Apps Script
  2. Delete any placeholder code and paste this:
function MY_BIZ_SHEET_NAME() {
return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}
  1. Click Save or press CMD+S [Mac] or CTRL+S to save [Windows & Linux]
  2. Close the Apps Script editor
  3. 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

  1. In the same Apps Script editor, add this too:
function MY_BIZ_ENCODE_URL(input) {
return encodeURIComponent(input);
}
  1. Save again
  2. 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

MethodDynamic?Safe?Requires Script?Notes
=MY_BIZ_SHEET_NAME() (Apps Script)Best method
MY_BIZ_ENCODE_URL(MY_BIZ_SHEET_NAME())For use in URLs
Manual entryFor 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.


Disclaimer: The content in this post is for educational purposes only. Always remember to take a backup before doing any of the suggested steps just to be on the safe side.
Referral Note: When you purchase through a referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer