Sorting of worksheets in a workbook

If the number of sheets in your workbook approaching to several dozen then sooner or later will be a desire to do sorting in the workbook. Standard tools don’t allow doing this. So we have to write own macro, which will do that.

Open menu Service - Macros - Visual Basic Editor, insert new module (menu Insert - Module) and copy text of this macro there:

Sub SortSheets()
Dim I As Integer, J As Integer

For I = 1 To Sheets.Count - 1
For J = I + 1 To Sheets.Count
If UCase(Sheets(I).Name) > UCase(Sheets(J).Name) Then
Sheets(J).Move Before:=Sheets(I)
End If
Next J
Next I
End Sub

Now the macro can be run through menu View - Macros – View Macros (ALT+F8) and it quickly sorts all the sheets in the current workbook.

Related articles:

Worksheet collection