if able, how do you sort Tabs in excel (alpha-numeric) ??

D

Dgadgetk

if able, how do you sort Tabs in excel (alpha-numeric) ??
...
I have multiple tabs/Worksheets created, each is named after a person.
Periodically, new worksheets are added for new names. I am trying to auto
sort the tabs/worksheets by tab name; alpha=numerically. Can anyone say if or
how this can be done? I have Excel 2003, SP2. Thankx
 
M

Mike H

Hi,

Right click any of your sheet tabs, view code and pastes this in and run it

Sub Sortem()
Dim x As Long, y As Long
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 y
Next x
End Sub


Mike
 
G

Gord Dibben

Sub sort_sheets()
'Mike H June 13th, 2007
Dim i As Integer, J As Integer

For i = 1 To Sheets.Count - 1
For J = i + 1 To Sheets.Count
If UCase(Sheets(i).Name) > UCase(Sheets(J).Name) Then
Sheets(J).Move Before:=Sheets(i)
End If
Next J
Next i
End Sub


Gord Dibben MS Excel MVP
 
P

PBIndy

This worked great!! Thank you for making this so easy! Some of the other
posts were difficult to understand!!
 

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