PDA

View Full Version : [SOLVED] Sorting worksheets alphabetically



K. Georgiadis
03-01-2005, 09:03 PM
I inserted this question in a thread that was already marked SOLVED so, in case it is overlooked, let me pose it again as a new thread:

I have a question regarding Chuck Pearson's code to re: sorting worksheets alphabetically that was referenced in the thread regarding naming sheets according to the contents of a cell.

He explains that his code can be modified to start on Sheet1, Sheet2 or wherever. Is it possible to modify this code so that it only sorts a certain set of sheets, say for example, only sort from Sheet8 to Sheet20?

Jacob Hilderbrand
03-01-2005, 09:07 PM
Try this KB Entry (http://www.vbaexpress.com/kb/getarticle.php?kb_id=72). Change theses lines as desired.


FirstWSToSort = 1
LastWSToSort = Worksheets.Count

K. Georgiadis
03-01-2005, 09:16 PM
I can see how I can change FirstWSToSort = 8 but how do I make it sort between Sheets 8 and 20 if the workbook contains, say, 30 worksheets?

Jacob Hilderbrand
03-01-2005, 09:19 PM
LastWSToSort = 20

K. Georgiadis
03-01-2005, 10:10 PM
Thanks! Just to be sure, does the WS number refer to the position of the worksheet in the book (which is my assumption) or its original number? I insert and move worksheets around, so Sheet1 could be in just about any position in the workbook!

Jacob Hilderbrand
03-01-2005, 10:15 PM
This will sort based on the current position of the sheets.

K. Georgiadis
03-01-2005, 10:36 PM
Great! Thanks for the help

Jacob Hilderbrand
03-01-2005, 10:41 PM
You're Welcome :beerchug:

Take Care