Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Sort worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
donbowyer - 22 Sep 2006 08:08 GMT
I have a workbook with 20 named sheets.
How can I programmatically arrange them in alphabetical order?
--
donwb
Gary Keramidas - 22 Sep 2006 08:17 GMT
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 before:=Worksheets(M)
               End If
           Else
               If UCase(Worksheets(N).Name) < _
                  UCase(Worksheets(M).Name) Then
                   Worksheets(N).Move before:=Worksheets(M)
               End If
           End If
       Next N
   Next M

End Sub

Signature

Gary

>I have a workbook with 20 named sheets.
> How can I programmatically arrange them in alphabetical order?
> --
> donwb
donbowyer - 22 Sep 2006 13:06 GMT
Thangs Gary worked fine
Signature

donwb

> try chip pearson's code:
>
[quoted text clipped - 32 lines]
> > --
> > donwb
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.