Hello!
I found shg's code and I am trying to adapt it to my workbook.
Each workbook has a sheet named "Cover" and another labelled "TOC" and the other sheets have a mix of numbers and letters ("4500181 sn1", "4500181 sn2", "4500183", etc.).
I want to leave the "Cover" and "TOC" and then sort the other sheets that have number (or number/letter) names.
Here's the code I am working with:
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 Sheets(i).Name = "Cover" Then
' do nothing
Else
If StrComp(.Sheets(i).Name, .Sheets(j).Name, vbTextCompare) <> 1 Then
.Sheets(i).Move Before:=.Sheets(j)
Exit For
End If
End If
Next j
Next i
End With
End Sub
Anyone have any ideas?
Respectfully,
Lost
Bookmarks