Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort worksheets
I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order? -- donwb |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sort Worksheets (without VB) | Excel Worksheet Functions | |||
How do I sort Worksheets by name? | New Users to Excel | |||
Sort Worksheets | Excel Worksheet Functions | |||
Sort Numerically Worksheets via VB when creating a new worksheets | Excel Programming | |||
HELP sort 2 worksheets | Excel Programming |