+ Reply to Thread
Results 1 to 4 of 4

Help verifying worksheet names are in order lowest to highest

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Help verifying worksheet names are in order lowest to highest

    Hi,

    I have a workbook which has worksheets labeled as follows: "1_1", "1_2", "1_3"......etc......."2_1", "2_2", "2_3", ........etc

    In my program i have to assume that the worksheets are "in order" ie...."1_1" is before "1_2" and "1_2" is before "1_3" and so on.

    I want to write some code to do a quick check on the worksheet names to make sure they are "in-order". Since the names are text not sure the best way to do this........

    Any ideas?

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Help verifying worksheet names are in order lowest to highest

    If the sheets are named like that, probably the easiest thing to do would be to loop through all the worksheets converting the name to a decimal number by replacing the "_" with a "." and adding to an array. You can then pass the array to a function to check if it is ordered - Chip Pearson has 1 such function on his website, a simple search "pearson test array sorted" should find that page.
    Please Login or Register  to view this content.
    Excuse the brevity, using a tablet so what code is there was typed freehand...

    PS: I did try to update this in case you have names like 1_2_1 but the piggin' firewall objected and I lost the edited reply... Post back if that is the case and I'll try again.
    Last edited by cytop; 04-27-2017 at 02:38 PM.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Help verifying worksheet names are in order lowest to highest

    well, i tried converting "1_1" to a numerical value of 1.1

    Problem is ...........when converting "1_10" to a number i get the following 1.1

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Help verifying worksheet names are in order lowest to highest

    Ahhh, yes...

    No problem.

    Split the sheet names using the "_" as the delimiter and then convert firstly the 'Major' number to a value and then add the 'Minor' number, converted to a value and divided by 100, or 1000 if your workbook is crazy enough to have that many sheets.

    Please Login or Register  to view this content.
    You still need Chip Pearsons' Array function but I have tested it and it works as long as:
    • You are checking all the sheets.
    • They are all numbered in the same manner
    • There's only 1 level of 'minor' numbers

    Multiple levels of minor numbers (1_2_1) can be accommodated with another little tweak of the code...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Ranking order based on highest to lowest value
    By Pranuvins in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-29-2016, 04:10 AM
  2. [SOLVED] how to find the lowest to highest value and display the name who is the lowest and the hig
    By jasond1992 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 09-23-2015, 09:20 PM
  3. [SOLVED] Highest And Lowest Score Order
    By StickCity in forum Excel General
    Replies: 4
    Last Post: 11-12-2014, 11:22 AM
  4. Macro to copy lowest and highest 10 values from a worksheet
    By eegbiofeedbk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-24-2012, 02:17 AM
  5. [SOLVED] Arranging in order highest to lowest
    By neiluk121 in forum Excel General
    Replies: 7
    Last Post: 06-09-2012, 02:37 PM
  6. Replies: 6
    Last Post: 01-11-2012, 12:06 PM
  7. Sorting names and numbers in order with the highest total
    By Red Shoes in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2006, 04:30 AM

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