Hi,
I am seeking for help with regards to sorting sheet in ascending order (sheet 1 is before sheet 2 which is before sheet 3 and so on...) However, what I can find does not work after the workbook contains more than 9 sheets. For example, the code below will arrange sheet10 after sheet 1 and before sheet 2. Could you please advise me on this. Thank you
I am seeking for help with regards to sorting sheet in ascending order (sheet 1 is before sheet 2 which is before sheet 3 and so on...) However, what I can find does not work after the workbook contains more than 9 sheets. For example, the code below will arrange sheet10 after sheet 1 and before sheet 2. Could you please advise me on this. Thank you
Code:
Sub SortSheetsTabName()
Application.ScreenUpdating = False
Dim iSheets%, i%, j%
iSheets = Sheets.Count
MsgBox iSheets
For i = 1 To iSheets - 1
For j = i + 1 To iSheets
If Sheets(j).Name < Sheets(i).Name Then
Sheets(j).Move before:=Sheets(i)
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub