Sort Sheets Alphabetically-Excel VBA

Share Now


PROBLEM STATEMENT

Sort all worksheets in A-Z/Z-A order

For Example:

In the below screenshot worksheets are not sorted in any order.

After running macro, they will be arranged in systematic manner

SOLUTION


Sub Arrange_Sheets()
Dim Sort_Descending As Boolean
Dim count_Sheets As Integer
Dim i As Integer
Dim j As Integer
No_of_Sheets = Sheets.Count


'Change Flag As appropriate
Sort_Descending = False
For i = 1 To No_of_Sheets
For j = 1 To i
If Sort_Descending = True Then
If UCase(Sheets(i).Name) > UCase(Sheets(j).Name) Then
Sheets(i).Move Before:=Sheets(j)
End If
End If
If Sort_Mode_Descending = False Then
If UCase(Sheets(i).Name) < UCase(Sheets(j).Name) Then
Sheets(i).Move Before:=Sheets(j)
End If
End If

Next j
Next i
End Sub

STEPS TO PERFORM

1. Go to developer Tab else Press Alt + F11
2.Click on Visual Basic icon
3.Go to Insert click on Module
4.Paste below code in standard module



Share Now
November 14, 2019

0 responses on "Sort Sheets Alphabetically-Excel VBA"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    EC Analytics will help your business make better decisions by providing expert-level business intelligence (BI) services. Forecasting, strategy, optimization, performance analysis, trend analysis, customer analysis, budget planning, financial reporting and more. EC Analytics also offers Advanced Data Analytics training in corporate and retail.

    Social Media

    ECAnalytics-facebookECAnalytics_Linkedin

    Address:

    NM 23, SECTOR 14, OLD DLF COLONY,
    GURGAON (HARYANA)
    0124- 4601426

    EC Analytics Consulting @ 2019 ALL RIGHTS RESERVED