+ Reply to Thread
Results 1 to 11 of 11

ranking second number between two words

  1. #1
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174

    ranking second number between two words

    hi, can anyone help me please. i have a column of numbers. every so often in the column, there is the word 'start'. the amount of numbers between each 'start' varies, but i would like to put a 1 or a 0 in the column next to each number. i would like the second highest ranking number to get a 1 and all the others to get a 0.

    if the first and second numbers between two starts are equal, then i would like all numbers between the 'start' to get a 0.

    for example:

    start
    12 0
    23 0
    45 0
    34 1
    start
    23 0
    34 0
    45 0
    56 1
    68 0
    45 0
    34 0
    45 0
    start
    23 0
    23 0
    start


    I posted on here months ago and someone very kindly did an array formula for me, trouble is some of the sheets are so long now that the array takes a few minutes to work it out and load up

    As always, thanks if yyou can help

    regards, jamie

  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
    Perhaps this will do what you wish:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    Thanks alot! sheet loads in seconds (less than!) instead of minutes with the array formula.

    Thanks, jamie
    Last edited by shg; 04-08-2008 at 04:43 PM. Reason: deleted quote

  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
    You're welcome, glad it worked for you.

  5. #5
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    Quote Originally Posted by jamiepullen
    Thanks alot! sheet loads in seconds (less than!) instead of minutes with the array formula.

    Thanks, jamie
    actually, on checking it this morning, i am not sure it does work quite right some numbers are ranked correct and some just award a '1' to the last number in the sequence

    i get the following:



    Start
    99 0
    96 0
    106 0
    95 0
    97 0 This should be a '1'
    93 0
    78 0
    0 0
    0 1 This should be a '0'
    Start
    90 0


    yet some numbers in the sequence are correct:

    Start
    80 0
    68 0
    77 1
    0 0
    0 0
    0 0
    Start

    I am pretty sure i did it correct

    VBa editor> double clicked the sheet i want it to work on under 'project-vba project' and pasted the code into the box and saved it. I would be grateful for any more help if anyone can.....


    regards, jamie

  6. #6
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    sorry, on the above 99 should be a '1'

  7. #7
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    i have tried changing a few numbers etc in the code, but as i do not have a clue with vba, i am making a bit of a mess with it i think!!

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Try this:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    sorted it. you are an excel genius!!!

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Well, a genius would have gotten it right the first time ...

    You're welcome, Jamie.

  11. #11
    Forum Contributor
    Join Date
    07-16-2007
    Posts
    174
    Hope you do not think i am being ungrateful here, as you have saved me loads of time and hassle already, but i was wondering if anyone could apply one tiny change to the above?......

    I have played around and managed to assign a button to set the macro in action (which is a huge advancement for me!).

    anyway, if i have used the macro, it displays the 1s and 0s as it should, but if the data changes and i need to run the macro again, the previous 1s and 0s stay there and are added to by the new 1s and 0s from rerunning the macro (if that makes sense!) i have to hilight the old 1s and 0s and delete them before clicking to run the macro again. Is it possible to add a bit to the macro in order for it to clear the old 1s and 0s from the previous run before it calculates the current data?

    Like i said, you have saved me loads of hassle here, so if this is to much then i am still very grateful for the help you have given me so far

    regards, jamie

+ 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