Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Dave and/or Tom

Could you check my post named Sorting Worksheets Numerically please
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dave and/or Tom

You can try this:

Sub SortWorksheets()

Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean
Dim sN as String, sM as String
Dim MaxLen as Long

SortDescending = False
FirstWSToSort = 1
LastWSToSort = Worksheets.Count
For M = FirstWSToSort To LastWSToSort
If Len(Worksheets(M).Name) MaxLen Then
MaxLen = Len(Worksheets(M).Name)
End If
Next

For M = FirstWSToSort To LastWSToSort - 1
For N = M + 1 To LastWSToSort
sN = Right(Space(MaxLen) & _
UCase(Worksheets(N).Name), MaxLen)
sM = Right(Space(MaxLen) & _
UCase(Worksheets(M).Name), MaxLen)
If SortDescending = True Then
If sN sM Then
Worksheets(N).Move Befo=Worksheets(M)
End If
Else
If sN < sM Then
Worksheets(N).Move Befo=Worksheets(M)
End If
End If
Next N
Next M

End Sub

--
Regards,
Tom Ogilvy



"jnf40" wrote in message
...
Could you check my post named Sorting Worksheets Numerically please



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
Dave phlogiston appears in spreadsheet cell when I type Dave P tallsaint Excel Discussion (Misc queries) 2 September 4th 09 11:05 AM
Dave Peterson...HELP!!!! Lynda Excel Discussion (Misc queries) 2 October 1st 08 01:47 PM
Dave Peterson joelbeveridge Excel Discussion (Misc queries) 1 August 4th 06 02:55 AM
to Dave Peterson Ross Excel Discussion (Misc queries) 2 September 18th 05 04:45 PM
Dave - Wazooli Excel Programming 1 March 1st 05 11:46 PM


All times are GMT +1. The time now is 09:44 AM.

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

About Us

"It's about Microsoft Excel"