+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Sort tabs

Hybrid View

  1. #1
    Registered User
    Join Date
    10-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    2

    Sort tabs

    On excel tabs at the bottom each has a different name as I work they get moved around. Is there any way to reline them from a to z
    Thanks William

  2. #2
    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: excel tabs

    I requires VBA.

    Why not just drag them into the order you wish?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: excel tabs

    yes that is what I do working on them I drag them from one end to the other but at the end of the day I would like to hit a button and the tabs would all go back to where they were you see I have over 250 tabs and I really mess them up thank you looking in vba now hoping to find what I am looking for. you help a great deal

  4. #4
    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: excel tabs

    Sub SortMe()
        SortSheets
    End Sub
    
    Sub SortSheets(Optional wkb As Workbook = Nothing, _
                   Optional ByVal iBeg As Long = 1, _
                   Optional ByVal iEnd As Long = 2147483647)
        ' shg 2009-09
        ' Insertion-sorts sheets from iBeg to iEnd
    
        Dim i           As Long
        Dim j           As Long
    
        If wkb Is Nothing Then Set wkb = ActiveWorkbook
    
        With wkb
            If iBeg < 1 Then iBeg = 1
            If iEnd > .Sheets.Count Then iEnd = .Sheets.Count
    
            For i = iBeg + 1 To iEnd
                For j = iBeg To i - 1
                    If StrComp(.Sheets(i).Name, .Sheets(j).Name, vbTextCompare) <> 1 Then
                        .Sheets(i).Move Before:=.Sheets(j)
                        Exit For
                    End If
                Next j
            Next i
        End With
    End Sub

+ 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