Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
KymY
 
Posts: n/a
Default Sort EXCEL sheets into alphabetical order

I have a workbook with 50 sheets (1 for each employee).

How can I get Excel to sort these into alphabetical order ?

(From )

  #2   Report Post  
Rowan
 
Posts: n/a
Default

This macro should do it.

Sub SortSheets()

Dim sht As Worksheet
Dim mySht As Worksheet
Dim i As Integer
Dim endRow As Long
Dim shtNames As Range
Dim Cell As Range

Set mySht = Sheets.Add
mySht.Move befo=Sheets(1)

For i = 2 To Sheets.Count
mySht.Cells(i - 1, 1).Value = Sheets(i).Name
Next i

endRow = mySht.Cells(Rows.Count, 1).End(xlUp).row
Set shtNames = mySht.Range(Cells(1, 1), Cells(endRow, 1))

shtNames.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlNo, OrderCustom:=1

i = 2
For Each Cell In shtNames
Sheets(Cell.Value).Move befo=Sheets(i)
i = i + 1
Next Cell

Application.DisplayAlerts = False
mySht.Delete
Application.DisplayAlerts = True

End Sub


Regards
Rowan

"KymY" wrote:

I have a workbook with 50 sheets (1 for each employee).

How can I get Excel to sort these into alphabetical order ?

(From )

  #3   Report Post  
KymY
 
Posts: n/a
Default



"KymY" wrote:

I have a workbook with 50 sheets (1 for each employee).

How can I get Excel to sort these into alphabetical order ?

(From )
Thanks, mate - have pasted the script into my Lotus Organizer Tips notepad

  #4   Report Post  
David McRitchie
 
Posts: n/a
Default

Sorting worksheet tabs into alphabetical order:

A list of worksheets in a worksheet may be useful, but it is
not necessary in order to sort the worksheets, and since that
worksheet is deleted anyway wouldn't seem practical.

see SortAllSheets macro in
http://www.mvps.org/dmcritchie/excel/buildtoc2.htm .
--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I sort for the maximum values in each year in excel? The Wrightster Excel Discussion (Misc queries) 3 February 24th 05 05:43 PM
SORTING question Rebecca New Users to Excel 3 February 24th 05 05:35 PM
purchase order counter in excel purchase order template Brandy@baoco Excel Worksheet Functions 0 February 23rd 05 06:17 PM
Excel doesn't sort zip codes properly [email protected] Excel Discussion (Misc queries) 4 February 4th 05 12:30 AM
Can you sort text in a random order in Excel tbowden Excel Discussion (Misc queries) 3 February 1st 05 02:42 PM


All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"