+ Reply to Thread
Results 1 to 7 of 7

Index/Match with multiple results

  1. #1
    Registered User
    Join Date
    03-14-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Index/Match with multiple results

    Hi,

    I have a spreadsheet where I use the LARGE function to display the top 20 values (out of 50,000 rows). I then need to associate a name with each of the values. I can do this either with VLOOKUP or with INDEX/MATCH, but I run into a problem when 2 of the results are identical. Both the VLOOKUP and the INDEX/MATCH functions only return the first instance of the result...but I need to display both. Any idea on how I can accomplish this?

    Thanks,
    Nick...

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Index/Match with multiple results

    Perhaps you want to filter the data so only the appropriate row shows? Advanced Filters?

    We need a sample workbook to see exactly what you mean when you say "Display Both".
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Index/Match with multiple results

    Assuming your data is in A2:B100 and A2:A100 contains the Names and B2:B100 the associated values.

    Now Assume you have listed the top 20 in C2:C21, then D2 enter formula:

    Please Login or Register  to view this content.
    The formula must be confirmed with CTRL+SHIFT+ENTER and not just ENTER, then copied down.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    03-14-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Index/Match with multiple results

    Quote Originally Posted by NBVC View Post
    Assuming your data is in A2:B100 and A2:A100 contains the Names and B2:B100 the associated values.

    Now Assume you have listed the top 20 in C2:C21, then D2 enter formula:

    Please Login or Register  to view this content.
    The formula must be confirmed with CTRL+SHIFT+ENTER and not just ENTER, then copied down.
    That worked like a charm! Thank you. Now I have to figure out how it works.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Index/Match with multiple results

    The formula is a sort of Vlookup for multiple matches... It uses the Index() function which requires you to index the table or column to extract from and it requires the Row number to extract from which is gotten from this part: SMALL(IF($B$2:$B$100=C2,ROW($B$2:$B$100)-ROW($B$2)+1),COUNTIF($C$2:$C2,$C2))

    The Small() function just allows us to step up and extract one match at a time, starting from the first match found. It will extract only if a the number in column C is found in range B2:B100 and then it will return the corresponding row number within the range. The -ROW($B$2)+1 is added for robustness (incase you insert rows above, then the result won't skew) and to offset the number of rows from row the top of the sheet you are starting the indexing.

    The last COUNTIF($C$2:$C2,$C2) is the k factor for the Small() function, which is like a step factor in a For...next loop in VBA.

    The CSE confirmation is because it is an array formula and you have to confirm with those keys to make these formulas work.

    Then you copy down... The only thing that changes copying down is the COUNTIF($C$2:$C2,$C2) . again to determine the step or row number we're in, and it figures this out by counting how many times the same number has appeared from the top of the range to the current location.

    Hope this helps.

  6. #6
    Registered User
    Join Date
    01-26-2013
    Location
    Alaska
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Index/Match with multiple results

    I like this one, but it's not returning muliptle values for me, i'll keep looking

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

    Re: Index/Match with multiple results

    Better if you started a new thread.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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