+ Reply to Thread
Results 1 to 6 of 6

Sorting SOME Worksheets Alphabetically

Hybrid View

  1. #1
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sorting SOME Worksheets Alphabetically

    A variation:
    Sub demo()
        SortSheets Sheets("Start").Index + 1, Sheets("Spacer").Index - 1
    End Sub
    
    
    Public Sub SortSheets(Optional iBeg As Long = 1, _
                          Optional iEnd As Long = 32767, _
                          Optional wkb As Workbook)
        Dim i           As Long
        Dim j           As Long
    
        If wkb Is Nothing Then Set wkb = ActiveWorkbook
        
        With wkb
            If i < 1 Then i = 1
            If j > .Sheets.Count Then j = .Sheets.Count
            
            For i = iBeg + 1 To iEnd
                For j = iBeg To i - 1
                    If .Sheets(i).Name < .Sheets(j).Name Then
                        .Sheets(i).Move Before:=.Sheets(j)
                        Exit For
                    End If
                Next j
            Next i
        End With
    End Sub
    Last edited by shg; 09-01-2009 at 10:48 AM.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1