![]() |
How do I alphabetize sheet tabs within a worksheet?
|
How do I alphabetize sheet tabs within a worksheet?
On Wed, 2 Apr 2008 08:16:03 -0700, Michelle
wrote: You need a Macro to do that. Put this into a regular module: ================= Option Explicit 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 ======================== --ron |
How do I alphabetize sheet tabs within a worksheet?
Check your other post, too.
Michelle wrote: -- Dave Peterson |
How do I alphabetize sheet tabs within a worksheet?
On Wed, 02 Apr 2008 11:44:20 -0400, Ron Rosenfeld
wrote: On Wed, 2 Apr 2008 08:16:03 -0700, Michelle wrote: You need a Macro to do that. Put this into a regular module: By the way, I did not write this macro -- but I cannot recall where I found it. --ron |
All times are GMT +1. The time now is 12:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com