Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Sorting Worksheet Tabs

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

...then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Sorting Worksheet Tabs

Graig,

Try this

Sub Sortem()
LastSheet = Sheets.Count
On Error Resume Next
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If CLng(Sheets(ws2).Name) < CLng(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub


Mike

"Craig" wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Sorting Worksheet Tabs

BRILLIANT!!! Worked great! Thanks.

--
Craig


"Mike H" wrote:

Graig,

Try this

Sub Sortem()
LastSheet = Sheets.Count
On Error Resume Next
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If CLng(Sheets(ws2).Name) < CLng(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub


Mike

"Craig" wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Sorting Worksheet Tabs

Glad I could help

"Craig" wrote:

BRILLIANT!!! Worked great! Thanks.

--
Craig


"Mike H" wrote:

Graig,

Try this

Sub Sortem()
LastSheet = Sheets.Count
On Error Resume Next
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If CLng(Sheets(ws2).Name) < CLng(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub


Mike

"Craig" wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sorting Worksheet Tabs

See also
http://www.contextures.com/xlToolbar01.html

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Craig" wrote in message ...
BRILLIANT!!! Worked great! Thanks.

--
Craig


"Mike H" wrote:

Graig,

Try this

Sub Sortem()
LastSheet = Sheets.Count
On Error Resume Next
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If CLng(Sheets(ws2).Name) < CLng(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub


Mike

"Craig" wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Sorting Worksheet Tabs

Great...thanks Ron for the tip.

--
Craig


"Ron de Bruin" wrote:

See also
http://www.contextures.com/xlToolbar01.html

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Craig" wrote in message ...
BRILLIANT!!! Worked great! Thanks.

--
Craig


"Mike H" wrote:

Graig,

Try this

Sub Sortem()
LastSheet = Sheets.Count
On Error Resume Next
For ws = 1 To LastSheet
For ws2 = ws To LastSheet
If CLng(Sheets(ws2).Name) < CLng(Sheets(ws).Name) Then
Sheets(ws2).Move Befo=Sheets(ws)
End If
Next ws2
Next ws
End Sub


Mike

"Craig" wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.


--
Craig


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sorting Worksheet Tabs


I've updated the code on the web page to allow for sorting numeric
sheet names in numeric or text order.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Tue, 21 Apr 2009 11:12:09 -0700, Craig
wrote:

I'm using Excel 2003.

I've searched this site and have found sorting tips for worksheet tabs
(mainly Chip Pearson's VBA code).

However, this ONLY seems to work by assuming the named tabs are ALPHA. What
if all 100 of my tabs are numbers???

EXAMPLE:

If I have the following tabs labeled: 1, 12, 21, 2000, 350, 3100, 55, 520,
1120, 2500

..then after running the code I will get the following INCORRECT result:

1, 1120, 12, 2000, 21, 2500, 3100, 350, 520, 55

Is there a way around this? How do I do a NUMERIC sort??

Thanks for any and all help.

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
SORTING WORKSHEET TABS Tree Excel Worksheet Functions 1 July 16th 09 08:56 PM
Sorting Worksheet Tabs Craig Excel Discussion (Misc queries) 1 April 21st 09 07:34 PM
Sorting Worksheet Tabs Jaqi Excel Worksheet Functions 5 July 15th 08 08:54 PM
Sorting Worksheet Tabs The Rook[_2_] Excel Discussion (Misc queries) 1 October 24th 07 11:12 AM
Sorting Worksheet Tabs Rich Cooper Excel Programming 1 May 27th 04 03:33 PM


All times are GMT +1. The time now is 12:01 PM.

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"