+ Reply to Thread
Results 1 to 3 of 3

Vlookup to retun multiple values.

  1. #1
    Registered User
    Join Date
    11-28-2007
    Posts
    45

    Vlookup to retun multiple values.

    Can I use in any way the vlookup function and return all matches if there are multiple values? I mean, it should return the values of all the matches, not just the first one...If VBA is the only way can anybody help me to get a code ? Thanks !

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Vlookup to retun multiple values.

    This is possible to do, but not with VLOOKUP. With this kinda formula you can

    =INDEX(ReturnRange,SMALL(IF(SearchValue=ValuesRange,ROW(INDIRECT("1:"&ROWS(ValuesRange)))),ROW(A1)))

    Confirm it with Ctrl+Shift+Enter and copy down.
    Here used named ranges.

    SearchValue is J1
    ValuesRange = A1:A50
    ReturnRange = B1:B50

    Also, if you copy this formula down in 15 cell but you have only 7 matches, all other cell will be filled with #NUM! errors.
    To avoid this error"
    If you use 2007 ucan wrap this formula in IFERROR function... ie

    =IFERROR(Formula,"")

    If you use earlier version of excel you can wrap it into:
    1: =IF(ISERROR(Formula),"",Formula)
    2: =LOOKUP(REPT("Z",255),CHOOSE({1,2},"",Formula) ' This will work if ALL your outputs are TEXT
    3: =LOOKUP(99^99,CHOOSE({1,2},0,Formula) ' This will work if ALL your outputs are NUMBERS

    Last edited by contaminated; 06-19-2010 at 02:41 PM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup to retun multiple values.

    id avoid that and go for an index match with a helper but it depends on how big your data is
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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