2016-02-23

EXCEL/VBA - Sort sheets


Public Sub SortSheets()

    Dim xlSheet As Excel.Worksheet
    Dim xlSheet2 As Excel.Worksheet
    Dim currentUpdating As Boolean
   
    currentUpdating = Application.ScreenUpdating
    Application.ScreenUpdating = False
   
    For Each xlSheet In ActiveWorkbook.Worksheets
        For Each xlSheet2 In ActiveWorkbook.Worksheets
            If LCase(xlSheet2.Name) < LCase(xlSheet.Name) Then
                xlSheet2.Move before:=xlSheet
            End If
        Next xlSheet2
    Next xlSheet
    Application.ScreenUpdating = currentUpdating

End Sub

No comments:

Post a Comment