Sorting Sheets Tabs alphabatically....

  • Thread starter Thread starter S. Obaid
  • Start date Start date
S

S. Obaid

Hi,

Is it possible to sort the sheets tabs according to
their names.??

Thanx...

Syed
 
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

HTH
Cordially
Pascal
 
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
 
Back
Top