Rename Multiple Excel Tabs at Once: Step-by-Step
Excel has no built-in command to rename several sheet tabs in one action, but you can rename multiple tabs at once with a short VBA macro. The macro loops through selected sheets and applies a consistent naming pattern, such as a prefix plus a number, or replaces a common string in every tab name. This guide shows you how to do it safely, what to prepare, and how to fix the usual problems.
What You'll Need
- Excel for Windows or Mac (the VBA editor is available in both).
- A workbook saved as .xlsm (macro-enabled) if you want to keep the macro, or a copy you can discard after use.
- Basic familiarity with opening the VBA editor (Alt+F11 on Windows, Option+F11 on Mac).
- Sheet names that follow a predictable pattern, or a plan for how the new names should be generated (prefix, suffix, numbering, or find-and-replace).
Step-by-Step
- Save a backup copy first. Renaming is easy to reverse, but a macro that deletes or overwrites names is not. Save the workbook under a new name before you run anything.
- Decide the naming rule. Write down exactly what each tab should be called. For example: prefix every selected sheet with "Q1_", number them "Data_1" through "Data_10", or replace "Old" with "New" in every tab name. A clear rule prevents surprises.
- Select the sheets you want to rename. Hold Ctrl (Cmd on Mac) and click each tab, or hold Shift and click the first and last tab to select a contiguous range. The selected tabs appear grouped, and the workbook title bar shows "[Group]".
- Open the VBA editor. Press Alt+F11 (Windows) or Option+F11 (Mac). In the Project Explorer, right-click your workbook and choose Insert > Module. A blank module window opens.
- Paste a macro that renames only the selected sheets. Use a loop over
ActiveWindow.SelectedSheetsso the macro does not touch unselected tabs. A simple prefix-and-number example:
Adjust the string to match your rule. To replace text instead, useSub RenameSelectedTabs() Dim ws As Worksheet Dim i As Long i = 1 For Each ws In ActiveWindow.SelectedSheets ws.Name = "Data_" & i i = i + 1 Next ws End Subws.Name = Replace(ws.Name, "Old", "New"). - Run the macro. Press F5 while the cursor is inside the subroutine, or use Run > Run Sub/UserForm. The selected tabs are renamed in the order they appear in the workbook, not the order you clicked them.
- Check for errors. If a generated name is invalid (over 31 characters, contains : \ / ? * [ ], or duplicates an existing name), Excel stops with an error and some tabs may already be renamed. Note where it stopped and fix the rule before rerunning.
- Save and remove the macro if not needed. If you saved as .xlsm and do not want the macro to remain, delete the module (right-click it in the Project Explorer > Remove) and save again. If you used a disposable copy, simply close without saving the macro.
Common Mistakes
- Looping over all sheets instead of selected ones. Using
For Each ws In ThisWorkbook.Worksheetsrenames every tab, including ones you meant to leave alone. Always loop overActiveWindow.SelectedSheetswhen you want a subset. - Assuming click order is preserved. The macro processes sheets in workbook order (left to right), so numbering may not match the order you Ctrl-clicked. Arrange tabs first if order matters.
- Generating invalid or duplicate names. Excel rejects names longer than 31 characters, names with forbidden characters, blank names, and duplicates (case-insensitive). Build a check into your rule or test on a copy.
- Forgetting that renaming breaks formulas and references. Formulas that use sheet names, defined names, charts, and external links update automatically when you rename through Excel, but hard-coded text references in other sheets or in VBA code do not. Search for the old name after renaming.
- Running the macro with no sheets selected. If only one sheet is active, the macro renames just that sheet, which can look like nothing happened if the new name equals the old one.
Tips
- Use a naming convention that sorts naturally, such as zero-padded numbers (Data_01, Data_02), so tabs stay in order.
- Test the macro on a copy with two or three sheets before running it on a large workbook.
- If you only need to change one tab, double-click the tab and type the new name; no macro is needed.
- To rename many tabs by hand faster, use Alt+H+O+R (Windows) to open the Rename Sheet dialog, type the name, and press Enter, then repeat.
- Keep the macro in a personal workbook or a separate .xlsm file if you rename tabs often, so you do not have to paste it each time.
Troubleshooting
- "That name is already taken" error. Two sheets would get the same name. Add a unique counter or check existing names before assigning.
- "The name you entered is not valid" error. The generated name contains a forbidden character, is blank, or exceeds 31 characters. Shorten or clean the string.
- Macro does nothing. Confirm sheets are actually selected (tabs highlighted, title bar shows [Group]) and that the cursor is inside the correct subroutine before pressing F5.
- Macros are disabled. Excel may block macros from files downloaded from the internet. Check the yellow security bar and enable content only if you trust the file; otherwise paste the macro into a new workbook you created yourself.
- Formulas show #REF! after renaming. A reference pointed to a sheet name that no longer exists, usually because the old name was hard-coded in text. Use Find & Replace to update the old name to the new one.
- Some tabs renamed, then it stopped. The macro hit an invalid or duplicate name partway through. Fix the rule, then rerun only on the remaining sheets, or restore from your backup and start again.
Frequently Asked Questions
Can I rename multiple tabs at once without VBA?
No. Excel's interface renames one sheet at a time. Selecting multiple tabs and typing a name renames only the active tab. VBA is the practical way to batch-rename.
Does renaming a tab break formulas?
Formulas that reference the sheet by name update automatically when you rename through Excel or VBA. Hard-coded text in cells, comments, or other VBA code does not update and must be changed manually.
What characters are not allowed in sheet names?
Excel forbids : \ / ? * [ ] and limits names to 31 characters. Names cannot be blank, cannot begin or end with an apostrophe, and must be unique ignoring case.
Can I undo a batch rename?
Ctrl+Z does not undo VBA changes. Restore from the backup you saved before running the macro, or run a second macro that reverses the naming rule.
Will the macro work on Excel for Mac?
Yes, VBA is available in Excel for Mac. Use Option+F11 to open the editor, and the same code runs, though some older Mac versions have minor VBA differences.
How do I rename tabs based on a list in a column?
Loop through the selected sheets and read each new name from a range, for example ws.Name = Range("A" & i).Value. Validate each value first, because one bad name stops the loop.