How to look up a value in a list and return multiple corresponding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have tried the method written by Ashish Mathur but it is not working I need
assistance with returning multiple values
 
Oh, now I see the entire formula:

=IF(ISERROR(INDEX($A$1:$B$7,SMALL(IF($A$1:$A$7=$A$10,ROW($A$1:$A$7)),ROW(1:1)),2)),"",INDEX($A$1:$B$7,SMALL(IF($A$1:$A$7=$A$10,ROW($A$1:$A$7)),ROW(1:1)),2))

Where most people have problems with these types of formulas is in this
portion:

ROW($A$1:$A$7)

ROW() is simply a means of generating an array of numbers from 1 to n that
correspond to the total number of elements in the Index function. In the
formula, the Indexed range, B1:B7, holds a total of 7 elements. So,
ROW(A1:A7) generates an array from 1:7.

Here's where people get this messed up:

Assume the Indexed range is B11:B17. That still contains a total of 7
elements so we still need the ROW function to generate an array from 1 to 7.
A lot of people would use this: ROW(B11:B17). However, that would generate
an array from 11:17 and since the Indexed array is from 1:7 the formula
crashes.

The best way to prevent this problem is to subtract the offset of the range
then add 1:

ROW(B11:B17)-ROW(B11)+1

Now that generates the array we need: 1:7

I would write that formula as:

=IF(ROWS($1:1)<=COUNTIF(A$1:A$7,A$10),INDEX(B$1:B$7,SMALL(IF(A$1:A$7=A$10,ROW(A$1:A$7)-ROW(A$1)+1),ROWS($1:1))),"")

Biff
 
Biff,

I thank you for your response however I am getting a !VALUE#. I can forward
the workbook to you so that you can see what I want to do and possibly come
up witht he formula.
 
Hi!

Did you enter the formula as an array?

How about posting the details?

Biff

Jerry said:
Biff,

I thank you for your response however I am getting a !VALUE#. I can
forward
the workbook to you so that you can see what I want to do and possibly
come
up witht he formula.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top