![]() |
Sort worksheets
I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order? -- donwb |
Sort worksheets
try chip pearson's code:
Sub AlphaSortWorksheets() Dim N As Integer Dim M As Integer Dim FirstWSToSort As Integer Dim LastWSToSort As Integer Dim SortDescending As Boolean SortDescending = False FirstWSToSort = 1 LastWSToSort = Worksheets.Count For M = FirstWSToSort To LastWSToSort For N = M To LastWSToSort If SortDescending = True Then If UCase(Worksheets(N).Name) _ UCase(Worksheets(M).Name) Then Worksheets(N).Move befo=Worksheets(M) End If Else If UCase(Worksheets(N).Name) < _ UCase(Worksheets(M).Name) Then Worksheets(N).Move befo=Worksheets(M) End If End If Next N Next M End Sub -- Gary "donbowyer" wrote in message ... I have a workbook with 20 named sheets. How can I programmatically arrange them in alphabetical order? -- donwb |
Sort worksheets
Thangs Gary worked fine
-- donwb "Gary Keramidas" wrote: try chip pearson's code: Sub AlphaSortWorksheets() Dim N As Integer Dim M As Integer Dim FirstWSToSort As Integer Dim LastWSToSort As Integer Dim SortDescending As Boolean SortDescending = False FirstWSToSort = 1 LastWSToSort = Worksheets.Count For M = FirstWSToSort To LastWSToSort For N = M To LastWSToSort If SortDescending = True Then If UCase(Worksheets(N).Name) _ UCase(Worksheets(M).Name) Then Worksheets(N).Move befo=Worksheets(M) End If Else If UCase(Worksheets(N).Name) < _ UCase(Worksheets(M).Name) Then Worksheets(N).Move befo=Worksheets(M) End If End If Next N Next M End Sub -- Gary "donbowyer" wrote in message ... I have a workbook with 20 named sheets. How can I programmatically arrange them in alphabetical order? -- donwb |
All times are GMT +1. The time now is 11:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com