+ Reply to Thread
Results 1 to 15 of 15

Ranking 1000 Sheets?

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Ranking 1000 Sheets?

    I have about 1000 sheets I need to rank in a workbook. Does anyone know if there's a quick way to do this with VBA? I want each row sorted high-to-low based on the "2012" column...and I'm trying to get the entire rows to move, not just the selection of cells underneath the 2012 column.

    I've attached a before/after example. Any help would be greatly appreciated:

    RankingExample.xlsx

  2. #2
    Valued Forum Contributor
    Join Date
    03-20-2011
    Location
    UK
    MS-Off Ver
    Excel 2007/10/16
    Posts
    840

    Re: Ranking 1000 Sheets?

    Please click on attachment

    Good luck
    Attached Files Attached Files
    To help you by my post? it would be nice to click on to say "Thank you".
    If you are happy with a solution to your problem?
    Click Thread Tools above your first post,
    select "Mark your thread as Solved".

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    Maybe:

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 02-21-2013 at 10:24 AM. Reason: code modification

  4. #4
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Ranking 1000 Sheets?

    Thanks, guys.

    Any idea how to make that automatically run for all of the sheets at once?

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    The code provided in Post 3 should do it for all sheets in the activeworkbook.

  6. #6
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Ranking 1000 Sheets?

    Hm...it doesn't seem to be working. I even tried selecting the specific sheets I wanted, but it only did it for the current one. Are there any adjustments that have to be made in order for it to run for multiple sheets?

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Ranking 1000 Sheets?

    John's code will loop through all sheets in your workbook and sort and rank every sheet.

    Alf

  8. #8
    Valued Forum Contributor
    Join Date
    03-20-2011
    Location
    UK
    MS-Off Ver
    Excel 2007/10/16
    Posts
    840

    Re: Ranking 1000 Sheets?

    John code is better than my code.
    My advice is use John code

    micope21

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    Quote Originally Posted by kestefon View Post
    Hm...it doesn't seem to be working. I even tried selecting the specific sheets I wanted, but it only did it for the current one. Are there any adjustments that have to be made in order for it to run for multiple sheets?
    Can you post the code you are using?

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Ranking 1000 Sheets?

    Sorry my bad, try this modification to John's code and see if this works better.

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    Alf is right. I forgot to activate the ws's.

  12. #12
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Ranking 1000 Sheets?

    I've attached a new example file with multiple sheets, along with the code you provided (I changed the name, but haven't modified the code itself).

    When I run it it only ranks the sheet I'm currently working on, and the others are unchanged...

    RankingExample - MULTIPLE SHEETS.xlsm

    Can you try the attachment and let me know whether you're having the same problem?

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    This works on the sample you provided and so does the modification that Alf provided.

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Ranking 1000 Sheets?

    Perfect! Thanks for the fix. Out of curiosity, do you know why it wasn't working before?

  15. #15
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ranking 1000 Sheets?

    You're welcome. Glad to help out and thanks for the feedback. I added ws.activate at the beginning of the loop. Each iteration of the loop you have to activate the spreadsheet. Please comply with Forum Rule No. 9.

    Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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