rsutton1981
New Member
- Joined
- Mar 9, 2016
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
Hi, I have some code that I modified from another thread. The code is to sort sheets based on a specific cell number on the sheet. My sheets are called "QM03-P1-R1" where the P and R number can be modified. The sheets are continually being created but not in a specific number. When I run the code it will sort in to P1, P1001, P1002, P11, P1102, P1851, P2, P201. Where I need it as P1, P2, P11, P201 P1001, etc. Can anyone help modify the code to help.
The code is below
The code is below
Code:
Dim WorkRng As Range
Dim WorkAddress As String
On Error Resume Next
xTitleId = "Sheet Sort"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Type D1", xTitleId, WorkRng.Address, Type:=8)
WorkAddress = WorkRng.Address
Application.ScreenUpdating = False
For i = 4 To Application.Worksheets.Count
For j = i To Application.Worksheets.Count
If VBA.UCase(Application.Worksheets(j).Range(WorkAddress)) < VBA.UCase(Application.Worksheets(i).Range(WorkAddress)) Then
Application.Worksheets(j).Move Before:=Application.Worksheets(i)
End If
Next
Next
Application.ScreenUpdating = True