Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Sort worksheets

I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order?
--
donwb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort worksheets

try chip pearson's code:

Sub AlphaSortWorksheets()

Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean

SortDescending = False
FirstWSToSort = 1
LastWSToSort = Worksheets.Count

For M = FirstWSToSort To LastWSToSort
For N = M To LastWSToSort
If SortDescending = True Then
If UCase(Worksheets(N).Name) _
UCase(Worksheets(M).Name) Then
Worksheets(N).Move befo=Worksheets(M)
End If
Else
If UCase(Worksheets(N).Name) < _
UCase(Worksheets(M).Name) Then
Worksheets(N).Move befo=Worksheets(M)
End If
End If
Next N
Next M

End Sub

--


Gary


"donbowyer" wrote in message
...
I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order?
--
donwb



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Sort worksheets

Thangs Gary worked fine
--
donwb


"Gary Keramidas" wrote:

try chip pearson's code:

Sub AlphaSortWorksheets()

Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean

SortDescending = False
FirstWSToSort = 1
LastWSToSort = Worksheets.Count

For M = FirstWSToSort To LastWSToSort
For N = M To LastWSToSort
If SortDescending = True Then
If UCase(Worksheets(N).Name) _
UCase(Worksheets(M).Name) Then
Worksheets(N).Move befo=Worksheets(M)
End If
Else
If UCase(Worksheets(N).Name) < _
UCase(Worksheets(M).Name) Then
Worksheets(N).Move befo=Worksheets(M)
End If
End If
Next N
Next M

End Sub

--


Gary


"donbowyer" wrote in message
...
I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order?
--
donwb




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
Sort Worksheets (without VB) Elgee Excel Worksheet Functions 4 August 16th 08 03:03 PM
How do I sort Worksheets by name? M Skabialka New Users to Excel 4 April 7th 05 06:15 PM
Sort Worksheets mate Excel Worksheet Functions 2 March 24th 05 11:05 AM
Sort Numerically Worksheets via VB when creating a new worksheets John Excel Programming 6 June 1st 04 07:21 AM
HELP sort 2 worksheets Malycom Excel Programming 2 February 16th 04 09:55 AM


All times are GMT +1. The time now is 06: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"