PDA

View Full Version : sort worksheets not case sensitive



lior03
03-12-2006, 12:45 AM
hello all
the following macro sort worksheets in a wb by name.
it is case sensitive.namely a sheets beginning with A comes before a.
i want the code to rank sheet by name regardless of case.

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


thanks

mdmackillop
03-12-2006, 02:10 AM
Hi Moshe
Add "Option Compare Text" before your code.
Regards
MD