+ Reply to Thread
Results 1 to 19 of 19

VLOOKUP on multiple columns

  1. #1
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    VLOOKUP on multiple columns

    I've used VLOOKUP based on matching one column and returning one result. No problem. Now I need to return one result based on 3 columns matching.

    Assume this range of columns is named: TravelDays
    Origin...Location...ShipVia...TravelDays
    33778...420...UPS...3
    33778...425...UPS...1
    33778...440...UPS...3
    33778...443...UPS...3
    33778...446...UPS...2
    33778...447...UPS...3
    33778...449...UPS...5
    33778...475...UPS...3

    What I'm trying to accomplish is if these columns match:
    i2=Lookup!TravelDays,1
    E2=Lookup!TravelDays,2
    N2=Lookup!TravelDays,3

    My result should be: Lookup!TravelDays,4

    How do I approach this?
    Thanks!

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

    Re: VLOOKUP on multiple columns

    I'm not following. Did you want to look up 3378 and 447 and UPS to get 3? Best choice for this is INDEX/MATCH and you will need to use an Array function.
    Is Origin in Col I, Location in E, and Ship Via in N?
    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

  3. #3
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    look up 33378 and 447 and UPS to get 3
    Correct.

    Is Origin in Col I, Location in E, and Ship Via in N
    I have a worksheet that I input data into and another worksheet named 'Lookup' where I hold my lookup ranges.
    The columns I, E and N on my worksheet must match the respective columns in my range named: TravelDays.

    INDEX/MATCH and you will need to use an Array function
    I believe you are correct. Off to more education!

    Thanks!

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

    Re: VLOOKUP on multiple columns

    The easiest thing would be for you to upload an example (Go Advanced>Manage Attachments)
    If you cannot do that, then be a little more specific as to column ranges and the names of the two sheets (separate workbooks or not?) and which is the one you are using the formula in and which is the one which is your reference?

    and it helps if you tell us which version of Excel you are using.

  5. #5
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    Using Excel 2007 with 2 worksheets in same workbook.
    Tab1 = PO
    Tab2 = Lookup

    Attached S1 screenshot shows the range TravelDays on the Lookup tab.

    On worksheet PO, I have 3 columns:
    I - Contains origin
    E - Contains ship to location
    N - Contains ship method

    Assuming I get a match on the above 3 columns with the respective columns in range TraveDays, I should get column 4 in TravelDays range.

    thanks!
    Attached Images Attached Images

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

    Re: VLOOKUP on multiple columns

    Okay, on some unknown column in PO, let's say in Row 5
    Let's say TravelDays is in Columns A,B,C and D so we want to return Column D
    You need to enter this ARRAYED formula

    =IFERROR(INDEX(Lookup!$D$2:$D$50, MATCH($I5&$E5&$N5, LOOKUP!$A$2:$A$50 & LOOKUP!$B$2:$B$50 & LOOKUP!$C$2:$C$50,0)), "")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

  7. #7
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    I don't think I'm communicating this very well. Let me try again.
    Range "TravelDays" is on worksheet "Lookup"
    Worksheet PO is where I input the criteria values.
    I2 must match Lookup!TravelDays column [Origin] and
    E2 must match Lookup!TravelDays column [Location] and
    N2 must match Lookup!TravelDays column [ShipVia]

    Assuming the above 3 columns are a match:
    Cell S2 on worksheet PO will reflect my desired result which will be Lookup!TravelDays column [TravelDays]

    Thanks!

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

    Re: VLOOKUP on multiple columns

    Maybe more clear if you upload you sample file, click "Go Advanced" button and find paperclip button to attach the file.

  9. #9
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    Attached is a sample

    thanks!
    Attached Files Attached Files

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

    Re: VLOOKUP on multiple columns

    Pretty much as I explained except you consolidated the columns. Take a look.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    In Excel, one should ba able to reference the range name and column number in formulas. Makes life simpler.

    Short Hand Example: TravelDays,1

    I noticed you code the above as $A$2:$A$9

    I switched your cell reference to TravelDays,1 and the formula errors.

    Is this short hand way of referencing a cell range not allowed in INDEX MATCH formulas? Or am I missing something again?

    Thanks for your help!

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

    Re: VLOOKUP on multiple columns

    Your name ranges select table include table header, that might be cause you error, change name ranges to just your data only

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

    Re: VLOOKUP on multiple columns

    It won't matter (azumi). What Excel needs to do in this case is create an entirely new Array combining the first three columns. That's why simply referring to TravelDays will not work. Excel creates this new array, commits it to memory, and then uses that to find a match.

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

    Re: VLOOKUP on multiple columns

    @ChemistB

    Sure do

  15. #15
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    The help is greatly appreciated. I ran into another issue. On the PO tab I provided 4 sample rows. As time passes there will be hundreds of rows. I tried adding more data rows then copying the formula vertically. Error: cannot change part of an array. I'm learning the quirks of arrays. Is there another way around this?

    thanks!

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

    Re: VLOOKUP on multiple columns

    Ah yes, the mysteries of arrays. Here's what I think might have happened.

    Normally, when you want to place the same constant or formula in multiple cells, you can select the range, type the formula into the active cell and hit CNTRL ENTER (or in the case of arrays CNTRL SHFT ENTER) and it fills in all your cells.

    HOWEVER, with an array, it links these cells as a single array. You need to create the array in the first cell. THEN, you can copy it down.

    If you created multiple cells as a single array (first paragraph), then you cannot change individual cells within that array.

  17. #17
    Registered User
    Join Date
    06-10-2014
    Location
    USA
    MS-Off Ver
    2019
    Posts
    13

    Re: VLOOKUP on multiple columns

    Shazam! It all works now.
    The help is much appreciated.

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

    Re: VLOOKUP on multiple columns

    Glad to help.

  19. #19
    Forum Expert boopathiraja's Avatar
    Join Date
    07-12-2013
    Location
    Coimbatore,TamilNadu, India
    MS-Off Ver
    Excel 2007, 2013, 2016, 365
    Posts
    1,455

    Re: VLOOKUP on multiple columns

    Hi, Check out an alternative way
    Attached Files Attached Files
    Click just below left if it helps, Boo?ath?

+ 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 - Single value lookup returning multiple records into multiple columns
    By kllovin in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-07-2014, 05:14 AM
  2. [SOLVED] VLOOKUP with Multiple Columns
    By cpalmer72 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2014, 01:55 PM
  3. Return multiple columns with vlookup when there are multiple matches
    By elapo21 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-06-2013, 07:11 PM
  4. Vlookup using multiple columns
    By hanez008 in forum Excel General
    Replies: 4
    Last Post: 08-22-2013, 11:17 AM
  5. [SOLVED] Vlookup on Multiple Columns
    By Delvesy888 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-19-2013, 07:52 PM

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