Sort Excel Workbook Tabs Alphabetically in Excel

Formulas & functions · Updated November 18, 2026

Excel does not have a built-in command that automatically sorts workbook tabs alphabetically. In Microsoft Excel for Microsoft 365 on Windows, you can arrange a few tabs by dragging them, or use a short VBA macro to sort all tabs by name.

Does Excel have a tab-sorting command?

No dedicated alphabetical-sort button appears on the worksheet-tab menu or the ribbon. Excel’s familiar Data > Sort commands sort rows of cell data; they do not rearrange worksheet tabs. This distinction matters because a workbook’s tabs are separate objects, not a column of values that Excel can sort with the usual sort dialog.

The practical choice depends on the workbook. For a handful of tabs, moving them by hand is straightforward and avoids enabling macros. For a workbook with many tabs, or one you expect to reorganize again, a VBA procedure can compare tab names and move them into order. Excel for the web does not run VBA, so use the manual approach there.

Arrange a small number of tabs manually

For a few sheets, drag each tab into its desired position. Excel places the sheet immediately before or after the tab where you drop it; watch the small insertion marker so you do not release it in the wrong spot. A useful manual method is to start at the left and repeatedly move the alphabetically earliest remaining tab into the next position.

  1. Decide what “alphabetical” means for your names, including how to treat numbers, punctuation, and accents.
  2. Identify the sheet that should be first, then drag its tab to the far-left position.
  3. Repeat with the earliest name among the tabs still to the right, placing it immediately after the tabs already sorted.
  4. Continue until the last tab is in place, then scan the full row from left to right.

If dragging is awkward, right-click a tab and choose Move or Copy. In the dialog, select the destination position in the list and move the sheet before that tab. The ribbon alternative in Windows is Home > Format > Move or Copy Sheet. These commands move one sheet at a time; they do not calculate an alphabetical order for you.

For example, if the tabs are Summary, East, Archive, and West, the target order is Archive, East, Summary, West. Move Archive to the front, then put East after it. Manual sorting is often the safest option when sheet order has a special meaning or when macros are not permitted.

Sort all tabs with a VBA macro

The following procedure sorts the workbook containing the code in ascending, case-insensitive name order. It uses Excel’s Sheets collection, so it includes chart sheets as well as worksheets. It repeatedly compares neighboring tabs and moves a tab left when the two names are out of order.

On Windows, first save a backup copy. Press Alt+F11 to open the Visual Basic Editor, choose Insert > Module, and paste the code below. Put the code in the workbook you intend to sort, because ThisWorkbook means the workbook that contains the macro. Run SortWorkbookTabsAZ from the editor with the cursor inside the procedure, or use Excel’s Developer > Macros command.

Sub SortWorkbookTabsAZ()
    Dim i As Long
    Dim swapped As Boolean

    Do
        swapped = False
        For i = 1 To ThisWorkbook.Sheets.Count - 1
            If StrComp(ThisWorkbook.Sheets(i).Name, _
                ThisWorkbook.Sheets(i + 1).Name, vbTextCompare) > 0 Then
                ThisWorkbook.Sheets(i + 1).Move Before:=ThisWorkbook.Sheets(i)
                swapped = True
            End If
        Next i
    Loop While swapped
End Sub

The macro changes tab positions, not sheet names or cell contents. It has no separate “undo” action: Excel’s Undo command cannot reverse a VBA macro. Save the backup before running it, and inspect the finished order. If you want to keep a macro in the workbook, save it as an Excel Macro-Enabled Workbook (.xlsm); saving as .xlsx does not preserve VBA code.

What the macro sorts—and what it does not

The code compares the names of every entry in ThisWorkbook.Sheets. That collection can include ordinary worksheets and chart sheets, and it also includes hidden sheets. Hidden tabs are not visible while hidden, but their positions can still be changed by the procedure. If you intend to sort only visible worksheets, this all-sheets macro is broader than that requirement; use a tailored macro or move tabs manually instead.

The comparison uses vbTextCompare, which makes uppercase and lowercase letters equivalent for comparison. Thus apples and Apples are not separated solely because of capitalization. The exact placement of names containing accented characters or other symbols can depend on the text-comparison rules available on the computer. If a fixed organization standard matters, agree on the naming convention and verify the result rather than assuming every locale will order every character identically.

Alphabetical order is not the same as “natural” number order. Since tab names are compared as text, names such as Report 1, Report 10, and Report 2 will generally be ordered as text, putting Report 10 before Report 2. If you want the sequence 1, 2, 10, use consistent zero-padding—Report 01, Report 02, Report 10—or choose a naming scheme that makes the desired order clear.

Choose the method that fits the workbook

  • Use drag-and-drop when there are only a few tabs, the order is a one-time change, or macro use is restricted.
  • Use Move or Copy when you need a precise position but dragging is difficult, such as in a crowded tab row.
  • Use VBA when there are many tabs and you want a repeatable alphabetic arrangement across the entire workbook.
  • Keep a custom order when tabs represent a process, chronology, presentation sequence, or other meaningful workflow rather than a directory of names.

Alphabetical order can make a large workbook easier to scan, particularly when sheets have descriptive names such as Accounts Payable and Accounts Receivable. It is less helpful when people depend on a fixed left-to-right sequence—for example, a monthly model arranged from January through December. In that case, sorting by name may make the tabs harder to use even though the result is technically alphabetical.

Check formulas, references, and workbook structure first

Reordering tabs usually does not change formulas that refer directly to a sheet by name, such as a formula linking to a particular worksheet. However, sheet order can affect three-dimensional references. For example, a formula using a range from one sheet through another includes sheets positioned between those boundary sheets. Moving a sheet into or out of that interval can therefore change which sheets contribute to the result.

Some workbooks also have macros, instructions, or operating procedures that refer to sheets by their tab positions rather than by stable names. A macro that uses a sheet index such as the first or third sheet may behave differently after tabs move. Before sorting a critical workbook, check for 3-D formulas, position-dependent VBA, and any documented order that users rely on. If you are unsure, make a copy and compare important results after the change.

Workbook structure protection is another possible obstacle. If the workbook’s structure is protected, Excel may prevent sheets from being moved, and the VBA macro can stop with an error when it tries. The workbook owner may need to unprotect the structure through Review > Protect Workbook before rearranging tabs. Do not try to bypass a password; ask the owner for the required access.

Windows, Mac, and Excel for the web

The ribbon path for moving one sheet in Excel for Microsoft 365 on Windows is Home > Format > Move or Copy Sheet. You can also use the tab’s right-click menu. Keyboard layouts and function-key settings vary, but Alt+F11 opens the VBA editor on many Windows installations. Excel may ask you to enable macros; only run code you understand and trust.

Excel for Mac supports VBA, although the way to open the editor can vary with the keyboard and Excel settings. Use the Developer > Visual Basic command if the Developer tab is available; on some Mac keyboards, Option+F11 or Fn+Option+F11 opens the editor. The macro itself uses standard VBA sheet-moving operations, but macro security and keyboard shortcuts may differ from Windows. Excel for the web does not run VBA macros. In the browser, rearrange tabs manually by dragging them; use the desktop app if you need to run the macro.

Common problems and practical fixes

  • The tabs do not look sorted by number: text sorting places “10” before “2.” Add leading zeroes to names when numeric sequence matters.
  • The macro reports an error while moving a sheet: check whether workbook structure protection is enabled and confirm the macro is in the workbook you want to sort.
  • Some tabs seem missing from the result: hidden sheets are included by this macro, but remain hidden. Review hidden sheets if their positions matter.
  • The macro is blocked: check the organization’s macro policy or use manual moves. Do not lower security settings just to run an unfamiliar file.
  • The order changes a report total: inspect formulas with sheet ranges such as FirstSheet:LastSheet, along with macros that rely on sheet indexes.

For a workbook used by several people, consider adding a short note to the workbook’s instructions that defines the intended ordering rule. “Alphabetical” can be ambiguous when names start with numbers, include prefixes, or differ only in capitalization. A consistent naming rule helps users recognize whether an unexpected position is a sorting issue or an intentional exception.

Frequently Asked Questions

Can Excel automatically sort sheet tabs alphabetically?
No built-in ribbon or tab-menu command does this. You can move sheets manually, or run VBA in the desktop version of Excel to automate the rearrangement.

Does the macro sort chart sheets too?
Yes. The sample uses the Sheets collection, which includes chart sheets as well as worksheets. It also includes hidden sheets, even though they are not visible in the tab row.

Can I sort tabs alphabetically in Excel for the web?
Excel for the web does not run VBA. You can drag tabs into order in the browser, or open the workbook in desktop Excel and use the macro there.

Will sorting worksheet tabs break formulas?
Direct references to named sheets generally remain linked to those sheets when moved. But moving tabs can change which sheets fall inside a three-dimensional reference, and it can affect macros that depend on sheet positions. Check those before sorting.

Can I sort tabs so Report 2 comes before Report 10?
Not with the sample’s plain text comparison. Name them with leading zeroes, such as Report 02 and Report 10, to make a text-based alphabetical sort match the intended numeric sequence.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.