+ Reply to Thread
Results 1 to 11 of 11

Need to return multiple instances using lookup

  1. #1
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Need to return multiple instances using lookup

    I'm trying to return multiple data for a lookup criteria.
    I've see this example mentioned before but did not see the solution....

    dog labrador
    dog beagle
    cat siamese
    bird toucan
    dog poodle

    Column A has the type of animal and Column B had the breed.

    On Sheet 2, I am trying to pull all the breeds for "dog". Lookup/match "dog" and find all breeds: labrador, beagle, poodle in successive rows.

    How can I do this?

    Thanks!
    Attached Files Attached Files
    Last edited by fugee7; 11-01-2011 at 02:12 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need to return multiple instances using lookup

    Hi,

    A VLOOKUP() function can only return one value. You need to use Data Filter.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Need to return multiple instances using lookup

    Yes I'm aware that vlookup can only return one value, I'm looking for a formula that is able to do that whether it is with index or some other function. Thanks.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need to return multiple instances using lookup

    No,

    Neither VLOOKUP(), INDEX(), MATCH() or any other single function or compound formula can return several results in the way you are expecting.

    As advised previously you need to check out the Data Filter functionality which will do exactly what you want.

    Regards

  5. #5
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Need to return multiple instances using lookup

    Data filter will not work for what I am trying to do.
    I saw this example on a different forum and someone provided the following as a solution:

    =IF(COUNTIF(Sheet1!B$1:B$5,A$1)>=ROWS($1:1),INDEX(Sheet1!A$1:A$5,
    SMALL(IF(Sheet1!B$1:B$5=A$1,ROW($1:$5)),ROWS($1:1))),"")

    Unfortunately, it didn't work for me exactly as also said by the other user but said he figured it out. So now, I don't know the solution.

    Maybe I wasn't clear, I'm not looking for one formula that will pull all 3 results. I'm looking for a formula that I can copy down that will result in the 3 values.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need to return multiple instances using lookup

    Hi,

    Data filter will work for what you are trying to do - see attached. If you don't like the AutoFilter then you can always use the Advanced Filter - or even a Pivot Table.

    It's difficult to comment on a formula in some un-named forum, which you agree didn't originally work for the original user, doesn't work for you and for which the data being analysed is known to neither of us.

    Regards
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Need to return multiple instances using lookup

    I am familiar with the data filter, advanced filter and pivot table. This was just purely an example, just filtering for the breed is not the end of the equation. I need something much more advanced as I have much more data. I need to pull the information into another sheet so I can continue to build the worksheet that I am working on.

  8. #8
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Need to return multiple instances using lookup

    Hi

    Using your example file:
    Sheet1!D1: =IF(A1=Sheet2!$A$1,ROW(),"")
    Copy down as required.

    Sheet2!A2: =IF(ROW()-1>COUNTIF(Sheet1!A:A,Sheet2!$A$1),"",INDEX(Sheet1!B:B,SMALL(Sheet1!D:D,ROW()-1)))

    Copy down as required.

    This should bring back your list of matching breeds, and put in a blank for those formulas that don't bring back an item.

    HTH

    rylo

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need to return multiple instances using lookup

    Thanks for the negative reputation. Your original post simply said
    On Sheet 2, I am trying to pull all the breeds for "dog". Lookup/match "dog" and find all breeds: labrador, beagle, poodle in successive rows.
    You didn't originally mention that you were aware of Data Filter, and since my suggestion did exactly what you were asking for I don't see why it justifies a negative response. Had it been completely irrelevant, completely wrong or no use at all then maybe.
    Last edited by Richard Buttrey; 11-01-2011 at 08:15 AM.

  10. #10
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Need to return multiple instances using lookup

    Sorry. Didn't really mean it to be negative. I thanked you for your help. I meant it more as I disagree.
    You're correct that I did not originally mention that I was aware of Data Filter but I did mention it later in the thread. I did mention that I was trying to pull the data into another sheet, Data Filter would not have helped with that. I also would have hoped that when you saw the formula I attached as an example that I was looking for something more advanced as I am working on something more complicated than filtering data.
    To me it was no use at all. But I didn't mean to offend you. Have a great day.

    Quote Originally Posted by Richard Buttrey View Post
    Thanks for the negative reputation. Your original post simply said


    You didn't originally mention that you were aware of Data Filter, and since my suggestion did exactly what you were asking for I don't see why it justifies a negative response. Had it been completely irrelevant, completely wrong or no use at all then maybe.
    Last edited by fugee7; 11-01-2011 at 02:03 PM.

  11. #11
    Registered User
    Join Date
    10-20-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Need to return multiple instances using lookup

    Thanks! This worked perfectly!

    Quote Originally Posted by rylo View Post
    Hi

    Using your example file:
    Sheet1!D1: =IF(A1=Sheet2!$A$1,ROW(),"")
    Copy down as required.

    Sheet2!A2: =IF(ROW()-1>COUNTIF(Sheet1!A:A,Sheet2!$A$1),"",INDEX(Sheet1!B:B,SMALL(Sheet1!D:D,ROW()-1)))

    Copy down as required.

    This should bring back your list of matching breeds, and put in a blank for those formulas that don't bring back an item.

    HTH

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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