jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
Hello, so I have the following code which successfully sorts the sheets in a workbook alphabetically when run.
I would like to make a couple of alterations to it. I would like it to:
1. Run automatically upon change to the number of tabs, e.g. when a sheet is added, and
2. Only to apply to sheets after a sheet called "Lookup"
Any thoughts? Many thanks.
I would like to make a couple of alterations to it. I would like it to:
1. Run automatically upon change to the number of tabs, e.g. when a sheet is added, and
2. Only to apply to sheets after a sheet called "Lookup"
Any thoughts? Many thanks.
Code:
Sub Sort_Tabs_Alphabetically()
For i = 1 To Application.Sheets.Count
For j = 1 To Application.Sheets.Count - 1
If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
Sheets(j).Move after:=Sheets(j + 1)
End If
Next
Next
End Sub