![]() |
Dave and/or Tom
Could you check my post named Sorting Worksheets Numerically please
|
Dave and/or Tom
You can try this:
Sub SortWorksheets() Dim N As Integer Dim M As Integer Dim FirstWSToSort As Integer Dim LastWSToSort As Integer Dim SortDescending As Boolean Dim sN as String, sM as String Dim MaxLen as Long SortDescending = False FirstWSToSort = 1 LastWSToSort = Worksheets.Count For M = FirstWSToSort To LastWSToSort If Len(Worksheets(M).Name) MaxLen Then MaxLen = Len(Worksheets(M).Name) End If Next For M = FirstWSToSort To LastWSToSort - 1 For N = M + 1 To LastWSToSort sN = Right(Space(MaxLen) & _ UCase(Worksheets(N).Name), MaxLen) sM = Right(Space(MaxLen) & _ UCase(Worksheets(M).Name), MaxLen) If SortDescending = True Then If sN sM Then Worksheets(N).Move Befo=Worksheets(M) End If Else If sN < sM Then Worksheets(N).Move Befo=Worksheets(M) End If End If Next N Next M End Sub -- Regards, Tom Ogilvy "jnf40" wrote in message ... Could you check my post named Sorting Worksheets Numerically please |
All times are GMT +1. The time now is 10:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com