Formula to match a value and return multiple results?

haste

New Member
Joined
Sep 27, 2011
Messages
5
Hi there,

I'm looking for a formula to match a value within an array and return the results found.

I know how to you use vlookup/match/index formula's, but I can only return the first match found. I would like to return the first match in cell A1 and the second match inside A2, third inside A3, etc.

So when the first match is found and placed inside A1 then the formula inside A2 should ignore the first match that is already found and show the next match value.

I would like to get this done with a formula and not with the autofilter option inside Excel.

I created an example: http://www.haste.nl/formula-filter.zip

Thanks for helping out!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi there,
I'm new to this forum and to Excel.
I'm looking for a formula that lookup an array after data is entered into a specific cell and return the corresponding results from multiple rows (as the data can be repeated in that same column)

I know a little about vlookup/match/index formula's, but I can only return the first match found. I would like to return all the matches found. I hope to get this done with a formula and not with the autofilter option inside Excel.
Below is an example of the Query form. Eg. User just enter the NRIC in the field and the formula would auto lookup the table and present the corresponding result as follows:
NRICS7898829H
Name:Julie
DateType of MedicationQTY

<tbody>
</tbody><colgroup><col><col><col></colgroup>

ABCD
Drug register
1DateNRICNameMedication
2
06/06/09

<tbody>
</tbody><colgroup><col></colgroup>
S7898829H

<tbody>
</tbody><colgroup><col></colgroup>
Julie

<tbody>
</tbody><colgroup><col></colgroup>
Mefenamic acid 250mg 2 cap tds

<tbody>
</tbody><colgroup><col></colgroup>
3
08/09/01

<tbody>
</tbody><colgroup><col></colgroup>
S7512835K

<tbody>
</tbody><colgroup><col></colgroup>
Timothy

<tbody>
</tbody><colgroup><col></colgroup>
Metronidazole 200mg 1 cap tds

<tbody>
</tbody><colgroup><col></colgroup>
4
08/06/09

<tbody>
</tbody><colgroup><col></colgroup>
S7310035H

<tbody>
</tbody><colgroup><col></colgroup>
Philip

<tbody>
</tbody><colgroup><col></colgroup>
Amoxycillin 250mg 2 cap tds

<tbody>
</tbody><colgroup><col></colgroup>
5
09/06/09

<tbody>
</tbody><colgroup><col></colgroup>
S5672900I

<tbody>
</tbody><colgroup><col></colgroup>
Peter

<tbody>
</tbody><colgroup><col></colgroup>
Arcoxia 90mg o.m

<tbody>
</tbody><colgroup><col></colgroup>
6
10/06/09

<tbody>
</tbody><colgroup><col></colgroup>
S7898829H

<tbody>
</tbody><colgroup><col></colgroup>
Julie

<tbody>
</tbody><colgroup><col></colgroup>
Arcoxia 90mg o.m

<tbody>
</tbody><colgroup><col></colgroup>
7
09/05/12

<tbody>
</tbody><colgroup><col></colgroup>
S7898829H

<tbody>
</tbody><colgroup><col></colgroup>
Julie

<tbody>
</tbody><colgroup><col></colgroup>
Fugentin 625mg 1 tab b.d

<tbody>
</tbody><colgroup><col></colgroup>
8
9

<tbody>
</tbody>
 
Upvote 0
Thanks in advance for any help... I had trouble attaching file in this forum, I hope the "table" helps.
 
Upvote 0
Hi and welcome to Mr Excel Forum

Say your data is in Sheet1 like this



A

B

C

D

1

Date​

NRIC​

Name​

Medication​

2

06/06/2009​

S7898829H​

Julie​

Mefenamic acid 250mg 2 cap tds​

3

08/09/2001​

S7512835K​

Timothy​

Metronidazole 200mg 1 cap tds​

4

08/06/2009​

S7310035H​

Philip​

Amoxycillin 250mg 2 cap tds​

5

09/06/2009​

S5672900I​

Peter​

Arcoxia 90mg o.m​

6

10/06/2009​

S7898829H​

Julie​

Arcoxia 90mg o.m​

7

09/05/2012​

S7898829H​

Julie​

Fugentin 625mg 1 tab b.d​

<TBODY>
</TBODY>



In Sheet2



A

B

1

NRIC​

S7898829H​

2

Name:​

Julie​

3

Date​

Type of Medication​

4

06/06/2009​

Mefenamic acid 250mg 2 cap tds​

5

10/06/2009​

Arcoxia 90mg o.m​

6

09/05/2012​

Fugentin 625mg 1 tab b.d​

<TBODY>
</TBODY>



Put the NRIC of interest in B1

Formula in B2
=VLOOKUP(B1,Sheet1!B:C,2,0)

Array formula in A4 copied down
=IFERROR(INDEX(Sheet1!A:A,SMALL(IF(Sheet1!$B$2:$B$100=$B$1,ROW(Sheet1!$B$2:$B$100)),ROWS(A$4:A4))),"")

confirmed with Ctrl+Shift+Enter simultaneously, not just Enter

Format A4, A5,....as Date

Array formula in B4 copied down

=IFERROR(INDEX(Sheet1!D:D,SMALL(IF(Sheet1!$B$2:$B$100=$B$1,ROW(Sheet1!$B$2:$B$100)),ROWS(B$4:B4))),"")

confirmed with Ctrl+Shift+Enter simultaneously, not just Enter

If you are not familiar with array formulas take a look at
Array Formulas

Hope this helps

M.
 
Upvote 0
Wow! Thank you so much, Marcelo Branco!
You are amazing and this is really great!
I'm impressed! I took several days to search around the net and experiment with formulas but to no avail.
thanks so much again!!!

MsTin

Hi and welcome to Mr Excel Forum

Say your data is in Sheet1 like this



A

B

C

D

1

Date​

NRIC​

Name​

Medication​

2

06/06/2009​

S7898829H​

Julie​

Mefenamic acid 250mg 2 cap tds​

3

08/09/2001​

S7512835K​

Timothy​

Metronidazole 200mg 1 cap tds​

4

08/06/2009​

S7310035H​

Philip​

Amoxycillin 250mg 2 cap tds​

5

09/06/2009​

S5672900I​

Peter​

Arcoxia 90mg o.m​

6

10/06/2009​

S7898829H​

Julie​

Arcoxia 90mg o.m​

7

09/05/2012​

S7898829H​

Julie​

Fugentin 625mg 1 tab b.d​

<TBODY>
</TBODY>



In Sheet2



A

B

1

NRIC​

S7898829H​

2

Name:​

Julie​

3

Date​

Type of Medication​

4

06/06/2009​

Mefenamic acid 250mg 2 cap tds​

5

10/06/2009​

Arcoxia 90mg o.m​

6

09/05/2012​

Fugentin 625mg 1 tab b.d​

<TBODY>
</TBODY>



Put the NRIC of interest in B1

Formula in B2
=VLOOKUP(B1,Sheet1!B:C,2,0)

Array formula in A4 copied down
=IFERROR(INDEX(Sheet1!A:A,SMALL(IF(Sheet1!$B$2:$B$100=$B$1,ROW(Sheet1!$B$2:$B$100)),ROWS(A$4:A4))),"")

confirmed with Ctrl+Shift+Enter simultaneously, not just Enter

Format A4, A5,....as Date

Array formula in B4 copied down

=IFERROR(INDEX(Sheet1!D:D,SMALL(IF(Sheet1!$B$2:$B$100=$B$1,ROW(Sheet1!$B$2:$B$100)),ROWS(B$4:B4))),"")

confirmed with Ctrl+Shift+Enter simultaneously, not just Enter

If you are not familiar with array formulas take a look at
Array Formulas

Hope this helps

M.
 
Upvote 0
You are amazing !!!

I'm looking for a formula to calculate which box # to use when shipping an item/items after the dimensions are entered in excel,



I have 2 sheets one sheet has the dimensions of the box sizes we carry and the dimensions of the boxes that are available , and the other sheet has the items and the dimensions that we have in stock ,


I would like enter the dimensions of the item or the the item # and excel should give me the best/smallest box size to use when shipping the item , keep in mind the box has to be bigger then the item we're trying to ship.






Example :

Sheet 1 with 4 Box sizes

ABCD
1444Box C4
2975.25Box 21
312108.75Box 30
414128Box 34

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>


Sheet 2 .. 8 items with the dimensions.


ABCDE
(item)(need the box # from sheet 1)
13.52.23.3crc 1
27.26.55crc 2
310.99.47.8crc 3
411.711.37.5crc 4
5564crc 5
623.53crc 6
79.59.57.7crc 7
8888crc 8

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>

if i would enter the [FONT=arial, sans-serif]dimensions of the item i'm looking to ship , the formula will look in [/FONT]sheet 1[FONT=arial, sans-serif] for the smallest box that the item will fit in and enter the box# in column E.

Thanks in advance
Jason[/FONT]
 
Upvote 0
Try this array formula in E1 copied down

=INDEX(Sheet1!D:D,SMALL(IF(Sheet1!$A$1:$A$4>=A1,IF(Sheet1!$B$1:$B$4>=B1,IF(Sheet1!$C$1:$C$4>=C1,ROW(Sheet1!$D$1:$D$4)))),1))

confirmed with Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,842
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top