OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 421
- Office Version
- 2019
- Platform
- Windows
Thanks in advance as I'll try to post feedback.
How do I alphabetize the sheets that are between the "Start" and "End" sheets. I have sheets before Start and End, but I want them to stay where they are. Now what's happening is all the sheets are being alphabetized.
How do I alphabetize the sheets that are between the "Start" and "End" sheets. I have sheets before Start and End, but I want them to stay where they are. Now what's happening is all the sheets are being alphabetized.
Code:
Sub Alp()
'_______________________________________________________________________________________________
'Turn on alerts, screen updates, and calculate
'Turn On Display Alerts
Application.DisplayAlerts = True
'Turn on Screen Update
Application.ScreenUpdating = True
'Turn off Automatic Calculations
Calculate
Dim Sht_Start As Long
Dim Sht_End As Long
Dim i As Long
Dim j As Long
'Alphabetize
Sht_Start = Worksheets("Start").Index - 1
Sht_End = Worksheets("End").Index - 1
For i = Sht_Start To Sht_End
For j = Sht_Start To Sht_End - 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
'_______________________________________________________________________________________________
'Turn on alerts, screen updates, and calculate
'Turn On Display Alerts
Application.DisplayAlerts = True
'Turn on Screen Update
Application.ScreenUpdating = True
'Turn off Automatic Calculations
Calculate
End Sub