Results 1 to 6 of 6

Thread: Worksheet Order

  1. #1
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a Excel spreadsheet that is automatically output from a system with 20 worksheets. Is it possible to kickoff a macro to order the worksheets by the names provided in an array? Any insight would be much appreciated.

  2. #2
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Yes a macro is possible
    are the worksheet names ordered alphabetically or in some other manner?
    What version of Excel?
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  3. #3
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Catharine,

    Thank you for your reply. I'm using Microsoft Office Excel 2003. The worksheets are ordered by a unique ID for each building (but I only display the name of the building on the worksheet tab).

    For example (ID is in parenthesis):

    Building Name
    (06) Building B
    (14) Building C
    (15) Building D
    (54) Building A

    I only display "Building A" on the worksheet tab. I'd prefer to have control over the order, for example, if I want Building D before Building B.

  4. #4
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Does the order change each time?
    The ID number you reference - is this the sheet number?
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  5. #5
    Star Lounger
    Join Date
    Jun 2009
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The building number really doesn't have much to do with the issue. It's not displayed anywhere. It's only used (via the web code) to generate the existing order. The worksheet tabs only display the building name (e.g. Building A). The order will not change each time.

  6. #6
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    how about something like this?
    Code:
    Sub reordersheets() 
    Sheets("BuildingB").Move before:=Sheets(1) 
    Sheets("BuildingC").Move after:=Sheets("BuildingB") 
    Sheets("BuildingD").Move after:=Sheets("BuildingC") 
    Sheets("BuildingA").Move after:=Sheets("BuildingD") 
    End Sub
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

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