Organize the worksheets in numerical order

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?
 
G

Gord Dibben

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
 
T

TGalin

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



.
 

Ask a Question

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.

Ask a Question

Top