Hi Syed
Yes, this is possible with a macro:
Sub sortsheets()
Dim X, I
For Each X In ActiveWorkbook.Sheets
For I = 2 To ActiveWorkbook.Sheets.Count
If Sheets(I - 1).Name > Sheets(I).Name Then
Sheets(I - 1).Move After:=Sheets(I)
End If
Next
Next
End Sub
I'd suggest one small change to this - as is, sheets starting with
lowercase characters will sort after sheets starting with uppercase
characters. This will sort alphabetically, regardless of case:
Public Sub SortSheets()
Dim oSheet As Variant
Dim i As Long
For Each oSheet In ActiveWorkbook.Sheets
For i = 2 To ActiveWorkbook.Sheets.Count
If UCase(Sheets(i - 1).Name) > UCase(Sheets(i).Name) Then _
Sheets(i - 1).Move After:=Sheets(i)
Next i
Next oSheet
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.