Worksheet order

T

Tracey

I have a workbook with about 20 worksheets. I would like to organize the
worksheets alphabetically by their tab name. Is there some way to do that
other than manually move the worksheets to the order I want? Thanks.
 
D

Don Guillett

Here are a couple of macros for that

Sub sortworksheets()
Dim Cnt As Integer
Dim n As Integer
Dim m As Integer
Dim WS As Worksheet
Set WS = ActiveSheet
Cnt = ActiveWorkbook.Worksheets.COUNT
For m = 1 To Cnt
For n = m To Cnt
If UCase(Worksheets(n).Name) < UCase(Worksheets(m).Name) Then
Worksheets(n).Move Before:=Worksheets(m)
End If
Next n
Next m
WS.Activate
End Sub

Sub sortworksheetsA()
Dim m As Integer
On Error GoTo EndOfMacro
Application.ScreenUpdating = False
Cnt = ActiveWorkbook.Worksheets.COUNT
For m = 1 To Cnt
For n = m To Cnt
If UCase(Worksheets(n).Name) < UCase(Worksheets(m).Name) Then
Worksheets(n).Move Before:=Worksheets(m)
End If
Next n
Next m
EndOfMacro:
Application.ScreenUpdating = True
End Sub
 
Top