alphabetize worksheet names

E

Eve Z.

Is there a way to alphabetize worksheet names in a workbook without having to
manually move each one?
 
D

Dave Peterson

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

John WEC

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
 
M

Mike H

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.
 

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