sort sheet tabs

  • Thread starter Thread starter Guest
  • Start date Start date
Hi,

For sorting sheets copy below code to your standard module
& run macro sortsheet.

---------------------------------------------------
Sub Sortsheet()
Quicksortsheets ' without arguments for ascending
'Quicksortsheets "D" ' with arguments for descending
end sub

Sub QuickSortSheets(Optional SortOrder)
Dim i As Long
Dim j As Long
Dim SheetsCount As Long
Dim FirstSheet As String
Dim NextSheet As String
Dim LValue As String
Dim HValue As String
Dim VTemp As String
Application.ScreenUpdating = 0
SheetsCount = Worksheets.Count
For i = 1 To SheetsCount \ 2
FirstSheet = Worksheets(i).Name
LValue = FirstSheet
HValue = FirstSheet
For j = i To SheetsCount - 1
NextSheet = Worksheets(j + 1).Name
If LValue > NextSheet Then LValue = NextSheet
If HValue < NextSheet Then HValue = NextSheet
Next
If IsMissing(SortOrder) Then
Else
VTemp = LValue
LValue = HValue
HValue = VTemp
End If
If LValue <> FirstSheet Then Worksheets
(LValue).Move before:=Worksheets(i)
If HValue <> Worksheets(SheetsCount).Name Then
Worksheets(HValue).Move after:=Worksheets(SheetsCount)
SheetsCount = SheetsCount - 1
Next
Application.ScreenUpdating = 1
End Sub


For a free add-ins, download "Workbook Navigation.xla"
from below site.

Reagards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
 
Back
Top