Forum Discussion
G_Elena
Sep 03, 2019Copper Contributor
Sort worksheets in Excel
Good day! Please tell me if Excel has a function for sorting worksheets
Subodh_Tiwari_sktneer
Sep 03, 2019Silver Contributor
If you are talking about Sorting Sheet Tabs in Ascending or Descending order, you may place the following Macros on a Standard Module like Module1 and run them as per your requirement.
To Sort Sheet Tabs in Ascending Order:
Sub SortSheetTabsAscending()
Dim ws As Worksheet
Dim i As Integer, j As Integer
Application.ScreenUpdating = False
Set ws = ActiveSheet
For i = 1 To Sheets.Count
For j = 1 To Sheets.Count - 1
If Sheets(j).Name > Sheets(j + 1).Name Then
Sheets(j).Move After:=Sheets(j + 1)
End If
Next j
Next i
ws.Activate
Application.ScreenUpdating = True
End Sub
To Sort Sheet Tabs in Descending Order:
Sub SortSheetTabsDescending()
Dim ws As Worksheet
Dim i As Integer, j As Integer
Application.ScreenUpdating = False
Set ws = ActiveSheet
For i = 1 To Sheets.Count
For j = 1 To Sheets.Count - 1
If Sheets(j).Name < Sheets(j + 1).Name Then
Sheets(j).Move After:=Sheets(j + 1)
End If
Next j
Next i
ws.Activate
Application.ScreenUpdating = True
End Sub