VBA to sort Sheets in descending order

noslenwerd

Board Regular
Joined
Nov 12, 2019
Messages
85
Office Version
  1. 365
Wondering if there is some VBA code that may look at sheets 2 through (sheet count), and sort them in descending order as shown?

I have a process that compares data between each sheet, and they must be in proper order. I do not trust the users to make sure these sheets are sorted correctly :)
Thanks!

Below is an example of the format in my workbook.
1618867241504.png
 
According to post #9 :​
VBA Code:
Sub Demo2()
              Dim S$(), V(), N&, A$
    With Sheets
        If .Count > 2 Then
            ReDim S(1 To .Count - 1)
            ReDim V(1 To .Count - 1)
        For N = 2 To .Count
            With .Item(N)
                S(N - 1) = .Name
                V(N - 1) = CLng(DateSerial(2000 + Right(.Name, 2), Left(.Name, 2), Mid(.Name, 3, 2)))
            End With
        Next
            V = Application.Match(Application.Large(V, Evaluate("COLUMN(" & [A1].Resize(, .Count - 1).Address & ")")), V, 0)
            A = ActiveSheet.Name
        For N = 1 To .Count - 2
            If .Item(N + 1).Name <> S(V(N)) Then .Item(S(V(N))).Move .Item(N + 1)
        Next
            Sheets(A).Select
        End If
    End With
End Sub
 
Upvote 0
Solution

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
In my previous code it's more obvious to use .Item(A).Select rather than Sheets(A).Select(The same for post #5)
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top