Get All Tab Names in Excel: Full Guide
In this article
To get all tab names in Excel, use either a built-in formula with a user-defined function (UDF) in VBA, Power Query, or a third-party add-in. The most reliable method for most users is creating a simple VBA function that loops through each worksheet and returns the names into a list on a worksheet.
Why Extract Tab Names in Excel?
- Organizing large workbooks with dozens of sheets
- Creating dynamic navigation menus or dashboards
- Documenting workbook structure for collaboration or audit purposes
- Preparing data for consolidation or reporting across multiple sheets
When managing complex Excel files—such as financial models, project trackers, or regional sales reports—sheet tabs often represent categories like months, departments, or locations. Manually listing them is time-consuming and error-prone. Automating the retrieval of tab names improves accuracy and efficiency, especially when the structure changes frequently.
How Excel Stores and Manages Sheet Names
Each worksheet in an Excel workbook has a Name property accessible via the Excel Object Model. This name is visible on the tab at the bottom of the workbook window and can be renamed by double-clicking it. Excel does not store a centralized list of sheet names within the worksheet environment itself—there is no native function like =SHEETNAMES() in standard Excel formulas (until newer versions with dynamic arrays).
The workbook object contains a Sheets or Worksheets collection, which can be accessed programmatically. Sheets includes all sheets (worksheets and chart sheets), while Worksheets refers only to worksheet tabs. This distinction matters when extracting names, as including chart sheets may not be desired.
Using VBA to List All Tab Names
Visual Basic for Applications (VBA) is the most widely used method to extract tab names. It allows you to create custom functions that return an array of sheet names.
- Press Alt + F11 to open the VBA Editor
- Go to Insert > Module
- Paste the following code:
Function ListSheetNames() As Variant
Dim ws As Worksheet
Dim SheetList() As String
Dim i As Integer
ReDim SheetList(1 To ThisWorkbook.Sheets.Count)
i = 1
For Each ws In ThisWorkbook.Sheets
SheetList(i) = ws.Name
i = i + 1
Next ws
ListSheetNames = Application.Transpose(SheetList)
End Function
- Close the editor and return to Excel
- In a blank column (e.g., A1), enter
=ListSheetNames() - Press Enter—the function will spill the list of tab names vertically
This function returns all sheet names from the current workbook. If you're using Excel 2019 or earlier without dynamic arrays, you must select a range of cells, type the formula, and press Ctrl+Shift+Enter to enter it as an array formula.
Using Power Query to Extract Tab Names
Power Query (Get & Transform in Excel 2016+) offers a no-code alternative to VBA. It can retrieve sheet names by querying the workbook structure.
- Go to the Data tab
- Click Get Data > From Other Sources > From Microsoft Query
- Select From Workbook
- Browse and select the current workbook file
- In the Navigator window, look for a table named Sheet Names or similar
- Select it and click Transform Data
You may need to filter rows where the Kind column equals "Sheet". Then, extract only the Name column. Once cleaned, load the query to a worksheet range. This method is dynamic: refreshing the query updates the list if tabs are added or renamed.
Native Excel Functions (Newer Versions Only)
Starting with Excel 365 and Excel 2021, new functions like SHEET and SHEETS are available, but they don't directly list all names. However, you can combine them with other techniques.
For example, =SHEETS() returns the total number of sheets. To get individual names, you'd still need indirect referencing. One workaround uses INDIRECT with a constructed reference:
=IFERROR(INDIRECT("'Sheet" & ROW(A1) & "'!A1"), "")
But this only works if you know the tab names follow a pattern like Sheet1, Sheet2, etc. It fails with custom names. Therefore, this method is limited and not reliable for arbitrary tab names.
Common Problems and How to Fix Them
- VBA Disabled: If macros are disabled, the function won’t run. Enable macros via Trust Center settings or save as .xlsm.
- Hidden Sheets: The default VBA code includes hidden sheets. To exclude them, modify the loop:
If ws.Visible = xlSheetVisible Then
- Order of Sheets: The list follows the tab order. To sort alphabetically, wrap the output in Excel’s
SORT()function:=SORT(ListSheetNames()) - External Workbooks: The function only reads the host workbook. To read another file, use file I/O methods in VBA, which require the file to be open.
Frequently Asked Questions
Can I get tab names without using VBA?
Yes, using Power Query is a viable no-code option. Open the current workbook as a data source in Power Query, then extract the sheet name metadata. This method avoids macros and works well for static reports or dashboards that are refreshed periodically.
Does this work in Excel Online?
No. VBA is not supported in Excel for the web. Power Query is also limited in the online version. You must use the desktop version of Excel (Windows or Mac) to run VBA or full Power Query features.
How do I update the list when I add a new tab?
If using VBA, press F9 to recalculate the worksheet. If the function is volatile, it updates automatically. For Power Query, click Refresh on the Data tab. The list updates to include new or renamed tabs.
Can I exclude specific sheets like Summary or Index?
Yes. Modify the VBA code to skip sheets by name. Add a condition inside the loop:
If ws.Name <> "Summary" And ws.Name <> "Index" Then
Wrap the name assignment in an If block to filter out unwanted sheets.
Why are chart sheets appearing in my list?
Because the Sheets collection includes both worksheets and chart sheets. To include only worksheet tabs, change ThisWorkbook.Sheets to ThisWorkbook.Worksheets in the VBA code. This ensures only standard data sheets are listed.
Is there a way to list tab names from another workbook?
Yes, but the target workbook must be open. In VBA, reference it by name: Workbooks("SalesData.xlsx").Sheets. If it's closed, you’ll need file system objects or ADO queries, which are more complex and may require error handling for missing files.