Sort sheets alphabetically


Posted by Beginner Bob on June 28, 2001 2:05 PM

I would like to be able to sort all sheets except sheet 1 in a workbook alphabetically. I guess I'd like to check order and sort in a workbook_sheetselectionchange macro, but I'm not sure where to put it, or how to write the code. Can someone help please! Thanks.

Posted by IML on June 28, 2001 2:35 PM

Asap utilities has the option to sort all sheets (including the first) alphabetically. If that is close enough, you can down load it from

www.asap-utilities.com/

good luck

Posted by G-Man on June 28, 2001 7:00 PM

IML,

Here is a sort routine someone shared with me some time ago:


Sub SortWorksheets()
Application.ScreenUpdating = False
Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean

SortDescending = False
FirstWSToSort = 1
LastWSToSort = Worksheets.Count

For M = FirstWSToSort To LastWSToSort
For N = M To LastWSToSort
If SortDescending = True Then
If UCase(Worksheets(N).Name) > _
UCase(Worksheets(M).Name) Then
Worksheets(N).Move Before:=Worksheets(M)
End If
Else
If UCase(Worksheets(N).Name) < _<br> UCase(Worksheets(M).Name) Then
Worksheets(N).Move Before:=Worksheets(M)
End If
End If
Next N
Next M
On Error Resume Next
End Sub

I have used it for a year or so and it works well.

HTH,

G-Man



Posted by Beginner Bob on July 06, 2001 11:12 AM

Thanks to both of you.

Thanks IML and G-Man for the help. I ended up using G-Man's code and it works great, and will definitely give ASAP's utility a try.