alphabetize worksheet names

  • Thread starter Thread starter Eve Z.
  • Start date Start date
E

Eve Z.

Is there a way to alphabetize worksheet names in a workbook without having to
manually move each one?
 
Chip Pearson and David McRitchie share code to sort sheets:

Chip Pearson's:
http://www.cpearson.com/excel/sortws.htm

David McRitchie's:
http://www.mvps.org/dmcritchie/excel/buildtoc.htm#sortallsheets

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 
Hi Eve

As Brad rightly says, this would require you to write a VBA sub procedure.
If you have a copy of John Walkenbach's excellent book "Excel 2002 Power
Programming with VBA" John actually uses this very subject as an example of
how to plan and build a VBA sub procedure. It starts on page 241 of his
book, and the finished procedure is listed on pages 253 & 254.

Regards
John WEC
 
try this

Sub Sortem()
For x = 1 To Worksheets.Count
For y = x To Worksheets.Count
If UCase(Sheets(y).Name) < UCase(Sheets(x).Name) Then
Sheets(y).Move Before:=Sheets(x)
End If
Next
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Back
Top