+ Reply to Thread
Results 1 to 12 of 12

Lookup value in a table and return adjacent column value

  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Lookup value in a table and return adjacent column value

    Hi

    I am trying to looup a value in a table and reurn the adjacent matched column value. I have used index and match formula with no success. Please see the attached sample table where I have given the results that hopefully a formula can return. The values in the table can be in any column, e.g. op 50 in column H, E.

    Thank you for your help.
    Attached Files Attached Files
    Last edited by hoss88; 12-05-2012 at 07:43 AM.

  2. #2
    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,630

    Re: Lookup value in a table and return adjacent column valu

    I can't really help you with the data as it is laid out. I'm not saying it's impossible, but I'm not going to be trying to do it.

    Excel works best with tables of data. So, imagine the data was laid out in a table in columns W, X, Y and Z:

    HTML Code: 

    The rows with no data could be left blank, if so required.

    Then you can set up a table that has two sub-tables: one that totals the qty, and one that totals sub

    HTML Code: 

    The beauty is that you then only need two fairly straightforward formulae, copied across and down:

    In B12: =SUMIFS($Y$3:$Y$20,$W$3:$W$20,$A12,$X$3:$X$20,B$11) and
    In I12: =SUMIFS($Z$3:$Z$20,$W$3:$W$20,$A12,$X$3:$X$20,B$11)


    That layout makes more sense to me as I feel it is easier to look at the groups rather than alternate columns.

    I hope this works for you.


    The other option, if you put your data in a table as described, is to use a Pivot Table.


    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


  3. #3
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Lookup value in a table and return adjacent column valu

    Hi
    Thank you for your prompt reply. If possible I would like to keep the format as it is - I have simplified the table and the actual data is lot more complex and i can't really change the format. the data is imported from SAP. So I would really appreciate if someone can help with the current format.

    thanks again.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup value in a table and return adjacent column value

    Try this in B11, dragged across and down

    =IFERROR(IF(B$10<>"sub", INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH(B$10, INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),),0) +1), INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH(A$10, INDEX($B$3:$S$5, MATCH($A11,$A$3:$A$5,0),),0)+2)),"")
    How's that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Lookup value in a table and return adjacent column value

    Thank you ChemistB - worked absolutely great, this saved a lot of time as I had struggled to find a solution for it. Thank you again for your help.

  6. #6
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Lookup value in a table and return adjacent column value

    Hi ChemisB

    hope you can read this. I tried to send the below message but your inbox was full. hope you could reply.

    Thanks again for solving my problem. I was new to the forum and it was my 1st post, but I wonder if I can ask you to solve a 2nd problem which is related to the post. I don't seem to be able to attach an example but will try to explain.
    I would like to return part of a cell value. the original table I had attached was simplified. for example all op20, op50, op60 etc have the material name before them, i.e. AA.op20, AA.op50, AA.op60 etc. therefore I like the formula to look for the "op.." part of the cell and return values as before.

    Hope that I have explained it clearly.

    Thank you again
    Hoss

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup value in a table and return adjacent column value

    Tough one. I will give it some thought.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup value in a table and return adjacent column value

    Okay, I thought about it.
    Assuming that it follows the pattern "material.OPxxx" and that "raw" and "fin" stand alone (or do they have Material. in front of them too?)

    Try
    =IFERROR(IF(B$10<>"sub", INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH(IF(LEFT(B$10,2)="OP",$A11&".","")&B$10, INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),),0) +1), INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH(IF(LEFT(A$10,2)="OP",$A11&".","")&A$10, INDEX($B$3:$S$5, MATCH($A11,$A$3:$A$5,0),),0)+2)),"")
    This formula is getting pretty complex.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup value in a table and return adjacent column value

    I overthought. This is simplier

    =IFERROR(IF(B$10<>"sub", INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH("*"&B$10, INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),),0) +1), INDEX(INDEX($B$3:$S$5,MATCH($A11,$A$3:$A$5,0),), MATCH("*"&A$10, INDEX($B$3:$S$5, MATCH($A11,$A$3:$A$5,0),),0)+2)),"")

  10. #10
    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,630

    Re: Lookup value in a table and return adjacent column value

    @ChemistB: Even more truly impressive formula. Sadly, no rep for this one

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup value in a table and return adjacent column value

    Thanks TM. We'll see if it works. Have a good day.

  12. #12
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Lookup value in a table and return adjacent column value

    Hi ChemisB

    Thank you again - your formula was exactly what I was looking for and is working great.

    Can't thank you enough - you have saved a lot of time for me.

    Thanks and have a nice day.
    Hoss

+ 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