SKFireworks
New Member
- Joined
- Mar 13, 2018
- Messages
- 4
I have documents with many tabs inside the worksheet and I would like to have the option to sort these tabs alphabetically. I have searched and tried adding the following module, but get an "Compile Error Syntex Error" I have the orriginal Document and could start over if needed. Any Help in this is appreciated.
After the Error Pop Up, I get another screen with the "Sub SortWorksheets()" highlighted in Yellow.
Below is the Module I am Using:
Sub SortWorksheets()
‘ sort worksheets in a workbook in ascending order
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
After the Error Pop Up, I get another screen with the "Sub SortWorksheets()" highlighted in Yellow.
Below is the Module I am Using:
Sub SortWorksheets()
‘ sort worksheets in a workbook in ascending order
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