SORTING WORKSHEETS

  • Thread starter Thread starter Barbara
  • Start date Start date
B

Barbara

Is there a way to sort worksheets? I have a workbook with
about 100 worksheets and I want to sort them in
alphabetical order. They were given to me randomly so I
couldn't really put them in order as I was going along.
I've right-clicked on Select All Sheets but can't figure
out a way to sort them so they all move and get in alpha
order. Thanks to anyone who can help me. I've been to the
MS website and read all the FAQs and Miss Crabby questions
and can't find anything on this subject.
 
Barbara,

This will sort all the sheets:

Sub SortAllSheets()

Dim iSheet As Integer, iBefore As Integer
For iSheet = 1 To ActiveWorkbook.Sheets.Count
Sheets(iSheet).Visible = True
For iBefore = 1 To iSheet - 1
If UCase(Sheets(iBefore).Name) > UCase(Sheets
(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move
Before:=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet

End Sub

Jill
 
Back
Top