+ Reply to Thread
Results 1 to 20 of 20

vlookup with multiple source and target columns

Hybrid View

  1. #1
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    vlookup with multiple source and target columns

    hi all.. i need help regarding vlookup using multiple columns and looking up also multiple target columns.

    i think i can do this using nested IFERRORs, but im hoping for a more elegant solution.

    i attached a file for example and also a screenshot.

    Capture.JPG
    Attached Files Attached Files
    Last edited by asrivera; 02-27-2019 at 11:13 AM.

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

    Re: vlookup with multiple source and target columns

    You have attached the file (thanks), and said what you think you need to use - but you forgot to tell us WHAT you are trying to do?
    I have a feeling you need to use INDEX/MATCH

    Which table is data, and which 1 is output?
    I also suggest that you use the exact same headings in both tables
    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

  3. #3
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    hi FDibbins..

    given the two tables, i need to vlookup the qty column (output) on the left table from the right table (data table).
    im having problems due to multiple columns on both tables.

    Quote Originally Posted by FDibbins View Post
    You have attached the file (thanks), and said what you think you need to use - but you forgot to tell us WHAT you are trying to do?
    I have a feeling you need to use INDEX/MATCH

    Which table is data, and which 1 is output?
    I also suggest that you use the exact same headings in both tables

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,411

    Re: vlookup with multiple source and target columns

    Do you mean that the Site Name columns (A to D) could be either in Site a1 or Site a2 columns ?

    It would help if you gave some idea of what you are expecting - please manually mock up some expected results and re-attach your workbook.

    Pete

  5. #5
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    Yes Mr. Pete.. that's what i mean..

    i have two tables from different sources, and i have to fill in the qty column (yellow) using the qty column from the 2nd table.

    Capture.JPG
    Last edited by asrivera; 03-04-2019 at 07:33 AM.

  6. #6
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,277

    Re: vlookup with multiple source and target columns

    Since in column "H" & "I" no duplicate > use in "E3"
    Formula: copy to clipboard
    =SUMPRODUCT(($H$3:$H$19=A3)*($H$3:$H$19=B3)*($J$3:$J$19))+SUMPRODUCT(($I$3:$I$19=C3)*($I$3:$I$19=D3)*($J$3:$J$19))


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  7. #7
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by avk View Post
    Formula: copy to clipboard
    =SUMPRODUCT(($H$3:$H$19=A3)*($H$3:$H$19=B3)*($J$3:$J$19))+SUMPRODUCT(($I$3:$I$19=C3)*($I$3:$I$19=D3)*($J$3:$J$19))
    What if value from col. B appear in col. I? Or from col. 3 in col. H?
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  8. #8
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by avk View Post
    Since in column "H" & "I" no duplicate > use in "E3"
    Formula: copy to clipboard
    =SUMPRODUCT(($H$3:$H$19=A3)*($H$3:$H$19=B3)*($J$3:$J$19))+SUMPRODUCT(($I$3:$I$19=C3)*($I$3:$I$19=D3)*($J$3:$J$19))
    thanks avk, but did not work.. also, it's possible to have duplicates in columns H & I, but i can easily remove if required.

    Capture.JPG

  9. #9
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    If you can create help column G like:
    =H3&I3
    and put something like (into E3)
    Formula: copy to clipboard
    =IFERROR(INDEX(J:J,MATCH("*"&INDEX(A3:D3,MATCH(1,COUNTIF($G$3:$G$19,"*"&A3:D3&"*"),0))&"*",G:G,0)),"")

    accept with CSE and drag it down

    Not tested so intensively.

  10. #10
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by KOKOSEK View Post
    If you can create help column G like:
    =H3&I3
    and put something like (into E3)
    Formula: copy to clipboard
    =IFERROR(INDEX(J:J,MATCH("*"&INDEX(A3:D3,MATCH(1,COUNTIF($G$3:$G$19,"*"&A3:D3&"*"),0))&"*",G:G,0)),"")

    accept with CSE and drag it down

    Not tested so intensively.
    Thanks Kokosek.. but also did not work.. nothing matched.

    Capture.JPG

  11. #11
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by asrivera View Post
    Thanks Kokosek.. but also did not work.. nothing matched.

    Attachment 614274
    Hmm weird. Check attached file. IMHO works fine.
    Did you accept formula with CSE?
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by KOKOSEK View Post
    Hmm weird. Check attached file. IMHO works fine.
    Did you accept formula with CSE?
    CSE!! i had to google that.. and now it works!! thanks so much! now i will play around with more columns

  13. #13
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: vlookup with multiple source and target columns

    Maybe put this on E3 and copied down as necessary

    =IFERROR(IFERROR(IFERROR(LOOKUP(1000,SEARCH(SUBSTITUTE($H$3:$H$19," ","*"),$D3),$J$3:$J$19),LOOKUP(1000,SEARCH(LEFT($H$3:$H$19,FIND(" ",$H$3:$H$19&" ")-1),$D3),$J$3:$J$19)),INDEX($J$3:$J$19,MATCH(C3,$I$3:$I$19,0))),"")
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    Quote Originally Posted by azumi View Post
    Maybe put this on E3 and copied down as necessary

    =IFERROR(IFERROR(IFERROR(LOOKUP(1000,SEARCH(SUBSTITUTE($H$3:$H$19," ","*"),$D3),$J$3:$J$19),LOOKUP(1000,SEARCH(LEFT($H$3:$H$19,FIND(" ",$H$3:$H$19&" ")-1),$D3),$J$3:$J$19)),INDEX($J$3:$J$19,MATCH(C3,$I$3:$I$19,0))),"")
    Thanks Azumi.. but also not working.. the formula is no longer matching if i remove some cells from the working table.

    Capture.JPG

  15. #15
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    i am actually able to do it with 4x2=8 nested iferror and vlookup.. but it's very crude and just plain ugly.. and also a pain to adjust for more columns.

  16. #16
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    You welcome

  17. #17
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    hi kokosek.. i think i found a bug in your formula..

    the values in yellow are not going as expected, not matching and partial matching..
    kindly check? thanks.

    Capture.JPG
    Attached Files Attached Files

  18. #18
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    Change G3 (helper) into:

    Formula: copy to clipboard
    =CHAR(160)&H3&CHAR(160)&I3&CHAR(160)


    and change E3 into:
    =IFERROR(INDEX(J:J,MATCH("*"&INDEX(A3:D3,MATCH(1,COUNTIF($G$3:$G$19,"*"&CHAR(160)&A3:D3&CHAR(160)&"*"),0))&"*",G:G,0)),"")
    accept with Ctrl+Shift+Enter (an drag it down as needed).

    Capture.JPG

  19. #19
    Registered User
    Join Date
    02-03-2019
    Location
    riyadh
    MS-Off Ver
    Office 365
    Posts
    23

    Re: vlookup with multiple source and target columns

    works perfectly! thanks so much kokosek!

  20. #20
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: vlookup with multiple source and target columns

    You welcome .

+ 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] vlookup target merged cells and return multiple rows
    By Joeun in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 09-14-2017, 04:06 AM
  2. Replies: 2
    Last Post: 03-18-2017, 02:05 AM
  3. [SOLVED]How to VLookup multiple items when the source has multiple identical numbers
    By jackson_hollon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-17-2014, 12:56 AM
  4. Help with If Target.Column - Multiple Columns
    By englishdanish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2014, 09:44 PM
  5. [SOLVED] Target multiple columns in a code
    By boboivan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2014, 06:40 AM
  6. VLOOKUP referring to columns to the left of the source column
    By makku in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-08-2008, 06:28 AM
  7. Variable VLOOKUP source and target
    By Vindaloo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-11-2006, 10:56 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