Skip to main content

How to sort worksheets in alphabetical / alphanumeric order in Excel?

Author: Kelly Last Modified: 2024-07-25

Sorting worksheets in Excel in alphabetical or alphanumeric order can greatly enhance the organization and efficiency of your workbook, especially when dealing with a large number of sheets. This guide will walk you through a few methods to achieve this, catering to various user comfort levels with Excel.

Sort worksheets in alphabetical / alphanumeric order with VBA code

Sort worksheets in alphabetical / alphanumeric order with Kutools for Excel


Sort worksheets in alphabetical / alphanumeric order with VBA code

There is a macro for sorting worksheets by alpha posted in the Microsoft Support center. We can apply it with following steps:

1.  Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2.  Click Insert > Module, and then paste the following macro in the Module Window.

VBA: Sort sheets in alphabetical / alphanumeric order

Sub SortWorkBook()
'Updateby Extendoffice
Dim xResult As VbMsgBoxResult
xTitleId = "KutoolsforExcel"
xResult = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) & "Clicking No will sort in Descending Order", vbYesNoCancel + vbQuestion + vbDefaultButton1, xTitleId)
For i = 1 To Application.Sheets.Count
    For j = 1 To Application.Sheets.Count - 1
        If xResult = vbYes Then
            If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
                Sheets(j).Move after:=Sheets(j + 1)
            End If
            ElseIf xResult = vbNo Then
                If UCase$(Application.Sheets(j).Name) < UCase$(Application.Sheets(j + 1).Name) Then
                    Application.Sheets(j).Move after:=Application.Sheets(j + 1)
            End If
        End If
    Next
Next
End Sub

3.  Press the F5 key to run this macro. In the following prompt box, click Yes, all the worksheets will be sorted by ascending alphabetical order; and click No, all the worksheets will be sorted by descending alphabetical order.

doc-sort-sheets-1

Sort worksheets in alphabetical / alphanumeric order with Kutools for Excel

Discover the ultimate assistant in Excel – Kutools for Excel's Sort Sheets tool! No matter how many worksheets you have, it effortlessly helps you organize them. It supports various sorting types, including Alpha Sort, Alpha Numeric Sort, Color Sort, and Reverse. Additionally, you can move worksheets up and down as you wish and easily reset the sorting. Make your Excel work more efficient and convenient!

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Enhanced with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. Click Kutools Plus > Worksheet > Sort Sheets. See screenshot:

doc-sort-sheets-kte-1

2. In the Sort Sheets dialog box, select one sorting type that you need on the right pane, such as Alpha Sort, Alpha Numeric Sort, and then click the OK button. See screenshot:

doc-sort-sheets-kte-2

Then all worksheets are sorted based on the specified sorting type. See screenshot:

doc-sort-sheets-kte-3

This article provides two methods to sort worksheets in alphabetical or alphanumeric order: VBA code and Kutools for Excel. Choose the method that best suits your needs. The VBA code method is suitable for those familiar with scripting and offers a highly customizable solution. Meanwhile, Kutools for Excel provides a user-friendly Sort Sheets tool that quickly and efficiently arranges all worksheets without any coding required. If you're interested in exploring more Excel tips and tricks, our website offers thousands of tutorials.


Related article:

Sort worksheet tabs by color


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

Comments (81)
Rated 5 out of 5 · 2 ratings
This comment was minimized by the moderator on the site
Grazie, ha funzionato perfettamente e mi ha risparmiato un sacco di lavoro. Complimenti
Rated 5 out of 5
This comment was minimized by the moderator on the site
Bom dia a macro funcionou porém com uma falha, veja no exemplo:
Abas (ANEXO 1, ANEXO 10, ANEXO 100, ANEXO 2, ANEXO 20)
Em uma planilha com os anexos acima ele organiza exatamente como está acima
Ele respeita a ordem somente a cada 10

Alguém sabe como corrigir? Olhei no font da macro mas não encontrei o problema
This comment was minimized by the moderator on the site
Macro qui marche parfaitement, en 30s c'est fait. Merci beaucoup
Rated 5 out of 5
This comment was minimized by the moderator on the site
Does anyone know how I would negate text from this macro? for example if my sheets were named "cafe 1st floor" and "kitchen 2nd floor" but id like to get rid of "cafe" and "kitchen"
thank you!
This comment was minimized by the moderator on the site
not working if your sheet was number ex: 1, 2, 10 12,
after sort: 1, 10, 12, 2
This comment was minimized by the moderator on the site
Hi Imd,
Do you mean all your sheet names are numbers and want to sort them ascending or descending? You can try the below VBA.

Sub Test1()

Dim i As Integer, j As Integer

For i = 1 To Sheets.Count

For j = 1 To Sheets.Count - 1

If Val(Replace(UCase(Sheets(j).Name), "SHEET", "")) > Val(Replace(UCase(Sheets(j + 1).Name), "SHEET", "")) Then Sheets(j).Move After:=Sheets(j + 1)

Next j

Next i

End Sub
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations