+ Reply to Thread
Results 1 to 8 of 8

VLookup across multiple columns, returning data if it exists

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2010
    Posts
    4

    VLookup across multiple columns, returning data if it exists

    Hello,

    I am trying to write a VLookup that will look across multiple columns, returning the data if it exists.

    Example:

    A______B________C_______D
    Acct__Widget 1__Widget 2__Widget 3
    X_______5
    Y________________________4
    Z________________7

    I want the VLookup to reference the account number (X,Y or Z) and return the value from either column B, C or D. If there is no data in any of the columns I would like it to return "N/A" or 0. The columns are mutually exclusive, so if there is data that exists it will only exist in one of the columns.

    I've tried using IF(ISNA(Vlookup...functions without much luck. Any help would be appreciated.

    Thanks.

  2. #2
    Registered User
    Join Date
    03-06-2014
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VLookup across multiple columns, returning data if it exists

    A B C D E
    Accnt W1 W2 W3 Answer
    X 2 2
    Y 6 6
    Z 5 5

    Type this formula in E2

    IF(VLOOKUP(A3,$A$3:$B$5,2,0)<>"",VLOOKUP(A3,$A$3:$B$5,2,0),IF(VLOOKUP(A3,$A$3:$C$5,3,0)<>"",VLOOKUP(A3,$A$3:$C$5,3,0),IF(VLOOKUP(A3,$A$3:$D$5,4,0)<>"",VLOOKUP(A3,$A$3:$D$5,4,0),"N/A")))

    Hope this helped you out, then click Add Reputation

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: VLookup across multiple columns, returning data if it exists

    This works as long as the data is numeric.

    Data Range
    A
    B
    C
    D
    E
    F
    G
    1
    Acct
    Widget 1
    Widget 2
    Widget 3
    -----
    Lookup
    Result
    2
    X
    5
    Z
    7
    3
    Y
    4
    4
    Z
    7


    This formula entered in G2:

    =SUM(INDEX(B2:D4,MATCH(F2,A2:A4,0),0))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: VLookup across multiple columns, returning data if it exists

    Try this formula

    =INDEX($B$2:$D$4, MATCH(A7,$A$2:$A$4,0),MATCH(1E+300,INDEX($B$2:$D$4,MATCH(A7,$A$2:$A$4,0),)))
    where B2:D4 is your data and A7 has the account you want to match
    See attachment
    Attached Files Attached Files
    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
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: VLookup across multiple columns, returning data if it exists

    Wow, Tony's is a great simplification over mine. I didn't know you could do that. Thanks Tony.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: VLookup across multiple columns, returning data if it exists

    ________

  7. #7
    Forum Contributor
    Join Date
    08-22-2012
    Location
    Czech republic
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: VLookup across multiple columns, returning data if it exists

    Quote Originally Posted by ChemistB View Post
    =INDEX($B$2:$D$4, MATCH(A7,$A$2:$A$4,0),MATCH(1E+300,INDEX($B$2:$D$4,MATCH(A7,$A$2:$A$4,0),)))
    Dear ChemistB, our Guru, please, could you explain what 1E+300 means? Thank you for that. Petr

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

    Re: VLookup across multiple columns, returning data if it exists

    1E300 is 1 times 10 to the 300th power or 1 followed by 300 zeros. Any large number which would be greater than the numbers in the cells would have sufficed.

+ 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 (or Index/Match) across four columns -- and returning multiple matches
    By rcasey in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-11-2013, 05:20 PM
  3. VLOOKUP not returning value when it definitely exists
    By tenscourts in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-21-2012, 11:10 AM
  4. Want to combine columns in rows where data exists from multiple sheets into one
    By bugmenot in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2009, 08:27 PM
  5. *Urgent* vlookup returning multiple columns
    By benj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2005, 02:28 AM

Tags for this Thread

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