HomeGoogle DocsSpreadsheetUse Current Sheet Name as a Criterion in Google Sheets

Use Current Sheet Name as a Criterion in Google Sheets

If you give meaningful names to your sheet tabs — like dates, project names, or categories — why not put them to use inside your formulas?

Say you’re entering daily data in a sheet named 2025-07-20. You want a formula that filters only that day’s data, and tomorrow, when you rename the sheet to 2025-07-21, the same formula should work without editing it. Sounds good, right?

Let’s see how to make that happen in Google Sheets — with a tiny script, a tick box to refresh the value, and a dynamic formula that uses the current sheet name as the filter criterion.

Get the Current Sheet Name Using Apps Script

We’ll start with a custom function that returns the current sheet name.

  1. Click Extensions > Apps Script
  2. Delete any placeholder code and paste this:
function SHEETNAME(dummy) {
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}

The dummy parameter lets the function recalculate when something changes — we’ll use that with a tick box.

  1. Name your project something like Current Sheet Name
  2. Click the floppy icon to save

Set Up a Refresh Mechanism for the Sheet Name

We’ll use one cell to refresh and another to hold the current sheet name.

  • Leave row 1 empty so it doesn’t interfere with your data
  • In A1, insert a checkbox (Insert > Tick box)
  • In B1, enter:
=SHEETNAME(A1)

Now, every time you check or uncheck the box, B1 refreshes with the current sheet name.

Bonus Tip: Convert the Sheet Name to a Date or Number

If your tab names are dates (like 2025-07-20), use this instead:

=TO_DATE(DATEVALUE(SHEETNAME(A1)))
Google Sheets formula returning the current sheet name using a custom Apps Script function

If they’re numbers (like 101 or 202), use:

=VALUE(SHEETNAME(A1))

Example: Use the Current Sheet Name in a Filter Formula

Here’s some sample data starting in A2:D:

Sample dataset to filter using current sheet name as a criterion in Google Sheets

Let’s say you want to filter this data based on the sheet name (which is a date). In cell F2, enter:

=FILTER(A3:D, A3:A = B1)

This filters rows where the Date (column A) matches the sheet name shown in B1.

How It Works in Practice

The idea is simple: rename the sheet, tick the box, and the formula updates automatically. You don’t need to touch the formula again — just rename the sheet as usual and click the checkbox to refresh.

Why It’s Useful

This trick is especially helpful when your workflow involves renaming or duplicating sheets regularly, because the formulas inside can adapt automatically based on the sheet name.

Here are a few examples:

  • In daily logs, when you duplicate yesterday’s sheet and rename it to today’s date, the formula updates itself to pull only today’s data — no edits needed.
  • In project tracking, each sheet might represent a different project. Rename the tab, and your formulas instantly adjust to match the new context.
  • In user dashboards, you can create one template sheet and simply rename it for each person — the formulas will still work correctly using the current sheet name.
  • And it’s not limited to just FILTER — you can use the current sheet name as a criterion in functions like XLOOKUP, XMATCH, COUNTIFS, and more, wherever a dynamic condition is needed.

No more hardcoding values — just rename the sheet and let the formulas handle the rest.

Prashanth K V
Prashanth K V
Your Trusted Google Sheets and Excel Expert Prashanth K V is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

How to Build a Dynamic Nonogram Clue Generator in Google Sheets

Over the past few months, I've built a couple of games in Google Sheets,...

Carpool Cost Splitter & Rotation Tracker in Google Sheets (Free Template)

Managing a carpool can be difficult, especially when you need to track whose vehicle...

How to Build a Road Trip Fuel Cost Splitter Formula in Google Sheets

Need a fair formula to split fuel costs among travelers on a long road...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.