Thread: Sort Worksheets
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Anant Basant Anant Basant is offline
external usenet poster
 
Posts: 30
Default Sort Worksheets

You can use the following macro:

Sub SheetSortMacro()

' Macro to work with chartsheets also

Dim shtCount As Long
Dim i As Long, j As Long

On Error GoTo MacroError

shtCount = ActiveWorkbook.Sheets.Count

For i = 1 To shtCount - 1
For j = i + 1 To shtCount
If UCase(Sheets(j).Name) < UCase(Sheets(i).Name) Then
Sheets(j).Move Befo=Sheets(i)
End If
Next j
Next i

ExitHe
Exit Sub

MacroError:
MsgBox Err.Description
Resume ExitHere
End Sub

--
Regards,
Anant


"Patrick C. Simonds" wrote:

Is there any way (using VBA code) to place all WorkSheets in a WorkBook in
alphabetical order?