Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Excel Macro to sort all worksheet alphabetically


The below code sorts all the worksheets in a workbook in alphabetical order

Sub SortSheetNames()
    ' Sort all the sheets alphabetically
    Dim i As Integer
    Dim j As Integer
    Dim totalSheets As Integer
    totalSheets = Sheets.Count
    For i = 1 To totalSheets - 1
        For j = i + 1 To totalSheets
            If Sheets(j).Name < Sheets(i).Name Then
                Sheets(j).Move Before:=Sheets(i)
            End If
        Next j
    Next i
    Application.ScreenUpdating = True
End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us