+ Reply to Thread
Results 1 to 12 of 12

Locating data in a table

Hybrid View

  1. #1
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    5

    Locating data in a table

    How can I locate 1000 or the closest number from column 5, and all the data to the left of it? I have tried all the commands I could find, and nothing has worked for me.

    This is the data I want to pull from the table.

    1.463 149.627 1.044 0.985 999.87

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    To find closest match to 1000 without going over:

    =MAX(IF(E2:E5000<=1000,E2:E5000))

    To extract data to the left:

    =INDEX(A2:A5000,MATCH($H$1,$E$2:$E$5000)) copied to the right, where H1 contains the previous formula result. You can also replace H1 with that formula (without the = sign)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    5
    I couldn't get that to work. I'm trying to search column 5 for the number 1000. When I used the formula, it gave me a number that was around row 1000 and a value of 5231.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by engrexcel View Post
    I couldn't get that to work. I'm trying to search column 5 for the number 1000. When I used the formula, it gave me a number that was around row 1000 and a value of 5231.
    I did forget to mention that the Max(If()) formula is an array formula and therefore must be confirmed with CTRL+SHIFT+ENTER not just ENTER....

    Go to that cell with the formula and hit F2..then Hold Ctrl+Shift keys and hit ENTER... you will see { } brackets appear and hopefully the correct result.

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Locating data in a table

    The Col_E values in your table are above and below 1000.
    If you want the data from the row where the Col_E value is "closest" to
    1000...even if it's larger than 1000.

    This formula finds that row
    F2: =MATCH(1,INDEX(--(ABS(1000-E2:E4501)=MIN(INDEX(ABS(1000-E2:E4501),0))),0),0)
    And this formula returns the Col_A data from that row
    G2: =INDEX(A2:A4501,$F2)
    Copy that formula across through K2

    BTW...these are the values from the row where the Col_E value is closest
    to 1000:
    G2: 11.213
    H2: 178.838
    I2: 0.263
    J2: 0.055
    K2: 999.985

    Does that help?
    Last edited by Ron Coderre; 10-24-2008 at 02:21 PM. Reason: Formula type....second F2 s/b G2
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    5
    Yes, that helped a ton! Thanks! Is there a way to get the formula so it grabs the data the first time 1000 is crossed? I'm not really concerned with any occurance of 1000 after it has been reached.

    1.463 149.627 1.044 0.985 999.87

    That was why I posted that set of numbers.

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Locating data in a table

    Using my posted example....Maybe this?

    This formula returns the row ref for the first instance where the series
    crosses 1000...either from below or above 1000.
    F2: =MATCH(1,IF(E2<=1000,INDEX((E2:E4500<=1000)*(E3:E4501>=1000),0),
    INDEX((E2:E4500>=1000)*(E3:E4501<=1000),0)),0)
    Does that work for you?
    Last edited by Ron Coderre; 10-24-2008 at 03:48 PM. Reason: enhance comment

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by engrexcel View Post
    Yes, that helped a ton! Thanks! Is there a way to get the formula so it grabs the data the first time 1000 is crossed? I'm not really concerned with any occurance of 1000 after it has been reached.

    1.463 149.627 1.044 0.985 999.87

    That was why I posted that set of numbers.
    Try:

    =INDEX(A$2:A$5000,MATCH(TRUE,$E$2:$E$5000>=1000,0)-1)

    confirmed with CTRL+SHIFT+ENTER and copied down.

  9. #9
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    5
    I tried to put a reference cell in the place of 1000 and I was given an error message.

    Is it not possible to put in a cell number instead of an actual number?

    Thanks

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Can you post the revised formula?

    Something like this should work.

    =INDEX(A$2:A$5000,MATCH(TRUE,$E$2:$E$5000>=C5,0)-1)

  11. #11
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    5
    =MATCH(1,IF(E18<=J9,INDEX((E19:E4000<=J9)*(E20:E4000>=J9),0),INDEX((E18:E4000>=J9)*(E18:E4000<=J9),0)),0)

    J9 = 6000

    I keep getting #N/A, but with the number (6000), it works.

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    That is quite different than the formula I had suggested for your initial question.

    I'm not sure I know what you are trying to do with that formula...

    You've got arrays of different sizes
    You've got conditions >=J9 and <=J9 will both be true when the value in the range actually equals J9...
    And your value if true is not much different than the value if false (which the range overlaps your condition check value (E18).

    Please explain in words what you are actually wanting to accomplish.

+ 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