![]()
Sub SortMe() SortSheets End Sub Sub SortSheets(Optional wkb As Workbook = Nothing, _ Optional ByVal iBeg As Long = 1, _ Optional ByVal iEnd As Long = 2147483647) ' shg 2009-09 ' Insertion-sorts sheets from iBeg to iEnd Dim i As Long Dim j As Long If wkb Is Nothing Then Set wkb = ActiveWorkbook With wkb If iBeg < 1 Then iBeg = 1 If iEnd > .Sheets.Count Then iEnd = .Sheets.Count For i = iBeg + 1 To iEnd For j = iBeg To i - 1 If StrComp(.Sheets(i).Name, .Sheets(j).Name, vbTextCompare) <> 1 Then .Sheets(i).Move Before:=.Sheets(j) Exit For End If Next j Next i End With End Sub
Bookmarks