User Agents

Web browsers and everyday web tech, explained

How to Reference Tab Name in Excel Formula

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Referencing a tab name in an Excel formula allows you to dynamically pull data from different worksheets based on the sheet's name, or use the name itself within calculations. This is particularly useful when building dashboards, summary sheets, or when consolidating data from multiple similarly structured tabs (e.g., monthly reports named January, February, etc.). While Excel doesn’t have a built-in function to directly return a worksheet’s name in a formula, you can achieve this using a combination of built-in functions, naming techniques, and sometimes a small user-defined function via VBA. This guide walks you through reliable methods to reference tab names in formulas, covering both formula-based and VBA-supported approaches.

What You'll Need

  • Microsoft Excel (2010 or later recommended)
  • A workbook with multiple worksheets
  • Basic knowledge of Excel formulas and cell references
  • Optional: Ability to enable macros if using VBA method

Step-by-Step

  1. Understand the limitation: Excel does not have a native worksheet.name function. You cannot directly retrieve a tab’s name with standard formulas like =TODAY() or =SUM(). You must use indirect methods.
  2. Use the CELL function to get the full file path: Enter =CELL("filename", A1) in any cell on the target worksheet. This returns the full path, file name, and sheet name in the format: [WorkbookName.xlsx]SheetName.
  3. Extract just the sheet name using text functions: Since CELL returns the full reference, combine it with FIND and MID functions. For example:
    =MID(CELL("filename", A1), FIND("]", CELL("filename", A1)) + 1, 255)
    This finds the closing bracket "]" and returns all text after it — the sheet name.
  4. Handle errors if the workbook hasn’t been saved: If the file is unsaved, CELL("filename") returns an empty string. Save the workbook first to ensure the function works.
  5. Create a named formula for reusability: Go to Formulas > Name Manager > New. Name it “SheetName” and set the refers to field to:
    =MID(CELL("filename", Sheet1!A1), FIND("]", CELL("filename", Sheet1!A1)) + 1, 255)
    Replace Sheet1 with the active sheet name. This named formula can now be used in any cell as =SheetName.
  6. Use the sheet name in dynamic references: Combine the extracted sheet name with INDIRECT to pull data. For example, if your sheet name is in cell A1, use:
    =INDIRECT(A1 & "!B2") to get the value from cell B2 of that sheet.
  7. Use VBA for a cleaner solution (optional): Press ALT+F11 to open the VBA editor. Insert a new module and paste:
    Function TabName() As String
    TabName = Application.Caller.Parent.Name
    End Function

    Close the editor. Now use =TabName() in any cell to return the current sheet’s name.
  8. Enable macros if using VBA: Save the file as .xlsm (macro-enabled). When opening, allow macros if prompted.
  9. Test across multiple sheets: Copy the formula or function to different tabs to confirm it returns each respective sheet name.
  10. Avoid circular references: Do not place the CELL or VBA function in a cell that’s referenced by the formula itself, especially in the CELL function’s reference argument.

Common Mistakes

One of the most frequent errors is forgetting to save the workbook before using CELL("filename") — unsaved files return no path, causing the formula to fail. Another mistake is referencing a cell on a different sheet within the CELL function, which returns that sheet’s name instead of the current one. Users also often miscount parentheses in nested formulas, leading to syntax errors. Using single quotes around sheet names in formulas without proper escaping (e.g., in INDIRECT) can break references, especially if the name contains spaces. Lastly, relying on VBA without saving as a macro-enabled file will cause the function to stop working after closing and reopening.

Tips

To improve reliability, always reference a stable cell like A1 in the CELL function. Use named ranges or formulas to centralize the sheet name extraction, making updates easier. If your sheet names contain special characters or spaces, wrap them in single quotes when using INDIRECT: =INDIRECT("'" & A1 & "'!B2"). Consider combining the sheet name with other data, like dates or categories, for dynamic reporting. For non-VBA users, bookmark the text extraction formula as a template. Use error handling like IFERROR to manage cases where the file isn’t saved yet.

Troubleshooting

If the formula returns a #VALUE! error, check that the workbook is saved and that the CELL function reference points to a valid cell on the current sheet. If the result is blank, verify that the file path includes the sheet name — unsaved files won’t return it. If using VBA and the function shows #NAME?, ensure macros are enabled and the module is correctly saved. If INDIRECT fails, confirm the sheet name string exactly matches the tab (including spaces and case) and use single quotes if needed. For broken links across workbooks, ensure external files are open or use full paths. If the formula works on one sheet but not another, check for typos or inconsistent referencing in the CELL function.

Frequently Asked Questions

Can I get the tab name without VBA?

Yes, using the CELL function combined with MID and FIND to extract the sheet name from the file path.

Why does my formula return an error?

Common causes include an unsaved workbook, incorrect cell reference in CELL, or syntax errors in nested functions.

Does this work in Google Sheets?

No, Google Sheets does not support the CELL("filename") method. Use custom functions with Google Apps Script instead.

Can I reference a tab name from another workbook?

Only if the external workbook is open; otherwise, the CELL function won’t retrieve the name.

What if my sheet name has spaces?

When using INDIRECT, wrap the sheet name in single quotes: 'Sheet Name'!A1.

Is there a way to list all tab names in a workbook?

Not with formulas alone. You need VBA or Power Query to extract a full list of worksheet names.