+ Reply to Thread
Results 1 to 11 of 11

Two variable look up from a table

  1. #1
    Registered User
    Join Date
    11-01-2014
    Location
    venezuela
    MS-Off Ver
    mac 2010
    Posts
    6

    Unhappy Two variable look up from a table

    Hello!

    I have been trying to solve this problem myself for a long time, but have failed to do so, I'll have to admit.

    I have a A1:AH14 table with values to specify the "schedule" of pipes depending on its thickness and diameter.

    I need to find that schedule with two values, as I said: thickness and diameter. The problem is that the thickness value is within the table and has to be located under the diameter that is given. Normally, the value of thickness is not exact as shown on the table, so the next available value has to be taken.

    I am attaching my table, so you get my point.

    Table.xlsx

    Please help!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Two variable look up from a table

    Hi,

    Since the values in the table are not in ascending order in each column this won't be easy with normal MATCH functions which require lists of values to be in order.

    It would be much simpler if you create a different layout for your table like the one below. Then the solution will be a simple VLOOKUP

    Please Login or Register  to view this content.
    The Schedule refs are before the _ and the diameters afterwards.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Two variable look up from a table

    This calcs what (i think) you want...
    =INDEX($A$3:$A$15,MATCH(B18,OFFSET(A1,2,MATCH($B$19,$B$1:$AH$1,0),13,1),1)+1)

    However, I would question how you arrive at your answer of 120 (A12), when the value you are searching for is 1.228 - which is less than 1.281, which would give you 100?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Two variable look up from a table

    I don't think your model will work. In your example, you say that you expect the schedule to be 120. However, 1.228 is less than 1.281 which is against schedule 100. 1.500 would return schedule 120.

    You also have duplicate values in the column. For example, you have two (2) 0.500 values. So it would be impossible to match against the second one, whatever mechanism you use to match values.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Two variable look up from a table

    @Ford: neat formula, though I am not a fan of OFFSET. But it seems to do the job.

    That said, there are lot's of opportunities for #N/A (eg: 22 and 0.249-) and #REF! (eg: 22 and 2.126+) errors.

    Regards, TMS

  6. #6
    Valued Forum Contributor
    Join Date
    10-14-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2019
    Posts
    353

    Re: Two variable look up from a table

    I used a few helper formulas: Match, Indirect and Index
    Attached Files Attached Files
    Kind regards,
    Piet Bom

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Two variable look up from a table

    Quote Originally Posted by TMS View Post
    @Ford: neat formula, though I am not a fan of OFFSET. But it seems to do the job.

    That said, there are lot's of opportunities for #N/A (eg: 22 and 0.249-) and #REF! (eg: 22 and 2.126+) errors.

    Regards, TMS
    @ Trevor, thanks, and I agree completely, I try and avoid OFFSET if I can and yes, there are some bugs in it, but I think they will return errors rather than wrong answers (except where they want the 2nd value of duplcates)

  8. #8
    Registered User
    Join Date
    11-01-2014
    Location
    venezuela
    MS-Off Ver
    mac 2010
    Posts
    6

    Re: Two variable look up from a table

    It was my mistake, I meant the opposite, the value of 1.228 should go with 1.281!

  9. #9
    Registered User
    Join Date
    11-01-2014
    Location
    venezuela
    MS-Off Ver
    mac 2010
    Posts
    6

    Re: Two variable look up from a table

    This is homework for a non-computer-related class. I've done a lot of formulas (for the first time in excel) and this is the last part, which has been impossible to me.

  10. #10
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Two variable look up from a table

    Hello Kriss,

    Try this array formula with CTRL+SHIFT+ENTER,

    =INDEX(A3:A15,MATCH(TRUE,INDEX(B3:AH15,,MATCH(B19,B1:AH1,0))>=B18,0))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  11. #11
    Registered User
    Join Date
    11-01-2014
    Location
    venezuela
    MS-Off Ver
    mac 2010
    Posts
    6

    Re: Two variable look up from a table

    Thank you so much everyone! You are really good!!

+ 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. Select column from table using variable table name -- VBA
    By jscott15 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-03-2016, 06:28 AM
  2. Replies: 1
    Last Post: 10-27-2012, 02:54 AM
  3. Replies: 3
    Last Post: 07-05-2012, 01:49 AM
  4. Variable File Reference and Variable Table Array in VBA VLOOKUP
    By Gingeiko in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2011, 11:08 PM
  5. How can i Append to Table using table Variable name
    By champs in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-18-2009, 04:34 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