Sort Worksheets in Alphabetical Order

This post will guide you how to sort worksheet tabs in alphabetical order in Excel. How do I sort worksheet by alphabetical order with VBA Macro code in Excel. How to quickly rearrange your worksheet tabs in alphabetical order with VBA code in Excel.

Sort Worksheets in Alphabetical Order


Assuming that you have 5 worksheets in your workbook, and you can sort worksheet tabs by manually. But what if there were 100 tabs? How to quickly sort worksheets? The best way is using VBA code to sort worksheets quickly. Let’s see the below detailed steps:

#1 open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.

Get the position of the nth using excel vba1

#2 then the “Visual Basic Editor” window will appear.

#3 click “Insert” ->”Module” to create a new module

convert column number to letter3

#4 paste the below VBA code into the code window. Then clicking “Save” button.

sort worksheets in alphabetical order1

Sub sortWorksheetTabs()
    Dim x As Long
    Dim y As Long
    For x = 1 To Worksheets.Count
        For y = x To Worksheets.Count
            If UCase(Sheets(y).Name) < UCase(Sheets(x).Name) Then
                  Sheets(y).Move before:=Sheets(x)
            End If
        Next
    Next
End Sub

#5 back to the current worksheet, then run the above excel macro. Click Run button.

sort worksheets in alphabetical order2

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar