Sub SortWorksheets()
Dim sCount As Integer, i As Integer, j As Integer
'Application.ScreenUpdating = False
sCount = Worksheets.Count
If sCount = 1 Then Exit Sub
For i = 1 To sCount - 1
For j = i + 1 To sCount
If Worksheets(j).Name < Worksheets(i).Name Then
Worksheets(j).Move Before:=Worksheets(i)
End If
Next j
Next i
End Sub
Sub sortem()
For a = 1 To Sheets.Count - 1
For b = a + 1 To Sheets.Count
If (Sheets(a).Name) > (Sheets(b).Name) Then
Sheets(b).Move Before:=Sheets(a)
End If
Next b
Next a
End Sub
You'll have to either adjust the code to convert the names to numbers--or use a
nice format for your worksheet names:
0001
0002
0011
0012
0020
0030
....
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.