Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Worksheets in Alphabetical Order (Left to Right)
Can anyone please suggest a way to organize the Worksheet Tabs i
alphabetical order running from left to right. Thanks in Advance -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Worksheets in Alphabetical Order (Left to Right)
In a standard module put:
Sub SortWorksheets() Dim N As Integer Dim M As Integer Dim FirstWSToSort As Integer Dim LastWSToSort As Integer Dim SortDescending As Boolean SortDescending = False If ActiveWindow.SelectedSheets.Count = 1 Then FirstWSToSort = 1 LastWSToSort = Worksheets.Count Else With ActiveWindow.SelectedSheets For N = 2 To .Count If .Item(N - 1).Index < .Item(N).Index - 1 Then MsgBox "You cannot sort non-adjacent sheets" Exit Sub End If Next N FirstWSToSort = .Item(1).Index LastWSToSort = .Item(.Count).Index End With End If 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 HTH - (Hope this helps) JMay "Jako " wrote in message ... Can anyone please suggest a way to organize the Worksheet Tabs in alphabetical order running from left to right. Thanks in Advance. --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Worksheets in Alphabetical Order (Left to Right)
Jako,
See this page at Chip Pearson's site: http://www.cpearson.com/excel/sortws.htm hth, Doug Glancy "Jako " wrote in message ... Can anyone please suggest a way to organize the Worksheet Tabs in alphabetical order running from left to right. Thanks in Advance. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting in Custom Alphabetical Order | Excel Worksheet Functions | |||
Sorting Cells in Alphabetical Order by Last Name | Excel Discussion (Misc queries) | |||
How do I put worksheets in alphabetical order | Excel Worksheet Functions | |||
sorting letters in words into alphabetical order | Excel Discussion (Misc queries) | |||
Worksheets in alphabetical order | Excel Programming |