SORTING WORKSHEETS

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.
 
J

Jill

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top