Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sort worksheets alphabetically (XP)

    I have a workbook with over 30 worksheets each with a name (in letters). How can I sort the worksheets to be in alphabetical order (A-Z)?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Sort worksheets alphabetically (XP)

    Here is a simple one, though for workbooks with a large number the sort might be slow and other algorithms could be used.

    Steve
    <pre>Option Explicit
    Sub SortSheets()
    Dim i As Integer
    Dim j As Integer
    For i = 1 To Sheets.Count - 1
    For j = i + 1 To Sheets.Count
    If UCase(Sheets(i).Name) > UCase(Sheets(j).Name) Then _
    Sheets(j).Move Before:=Sheets(i)
    Next j
    Next i
    End Sub</pre>


  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sort worksheets alphabetically (XP)

    Thanks. You also confirmed my fear that excel has no built-in function for this. For smaller workbooks with 5-10 sheets I think it may be just as fast or even faster to move (sort) them manually.

Posting Permissions

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