Organize the worksheets in numerical order

  • Thread starter Thread starter TGalin
  • Start date Start date
T

TGalin

I have a workbook with sheets that have similar names. The only difference
between the worksheet names is the numbers included in them. Is it possible,
using a macro, to organize the worksheets in numerical order?
 
Depends upon where "included numbers" are located in the sheet name.

Mike's macro will sort by numbers included within or at either end of sheet
names.

Sub sort_sheets()
'Mike H June 13th, 2007
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


Gord Dibben MS Excel MVP
 
Thank you. This is what I needed.

Gord Dibben said:
Depends upon where "included numbers" are located in the sheet name.

Mike's macro will sort by numbers included within or at either end of sheet
names.

Sub sort_sheets()
'Mike H June 13th, 2007
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


Gord Dibben MS Excel MVP



.
 
Back
Top