Help searching for strings in 2D array and returning multiple results

Sparhan

New Member
Joined
Mar 20, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have some data that looks something like this:

5/9/23​
AppleBananaBanana
6/9/23​
BananaGrapeGrape
7/9/23​
OrangeAppleWatermelon
8/9/23​
GrapeBananaMango
9/9/23​
MangoMangoApple

Basically I want to write a formula that finds all the occurances of 'Apple' within B1:D5 and then returns the corresponding date from column A . So the results would output like this:


5/9/23​
7/9/23​
9/9/23​

If it was looking for 'Mango' it would ideally return this (only reading each row once, thereby not duplicating the date):


8/9/23​
9/9/23​

I believe this is an array formula I need, but I just cannot work out how to get it to work. TIA!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello Sparhan

Mappe10
F
108.09.2023
209.09.2023
3
4
Tabelle1
Cell Formulas
RangeFormula
F1:F2F1=LET( data,TOCOL(A1:A5/(B1:D5="Mango")), numbers,ISNUMBER(data), result,UNIQUE(FILTER(data,numbers)), result)
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCD
105/09/2023AppleBananaBanana
206/09/2023BananaGrapeGrape
307/09/2023OrangeAppleWatermelon
408/09/2023GrapeBananaMango
509/09/2023MangoMangoApple
6
7
8Apple05/09/2023
907/09/2023
1009/09/2023
Data
Cell Formulas
RangeFormula
B8:B10B8=TOCOL(IF(B1:D5=A8,A1:A5,1/0),2)
Dynamic array formulas.
 
Upvote 0
Hello Sparhan

Mappe10
F
108.09.2023
209.09.2023
3
4
Tabelle1
Cell Formulas
RangeFormula
F1:F2F1=LET( data,TOCOL(A1:A5/(B1:D5="Mango")), numbers,ISNUMBER(data), result,UNIQUE(FILTER(data,numbers)), result)
Dynamic array formulas.
Hi @shift-del, this worked perfectly, thank you!

Is there a way at all of making it able to find results even if the string isn't an exact match, for example below if I wanted to find all "Mango" again and have it recognise the data in D2 as well as the others?

5/9/23AppleBananaBanana
6/9/23BananaGrapeMango and Banana
7/9/23OrangeAppleWatermelon
8/9/23GrapeBananaMango
9/9/23MangoMangoApple
 
Upvote 0
How about
Fluff.xlsm
ABCD
105/09/2023AppleBananaBanana
206/09/2023BananaGrapeMango and Banana
307/09/2023OrangeAppleWatermelon
408/09/2023GrapeBananaMango
509/09/2023MangoMangoApple
6
7
8Mango06/09/2023
908/09/2023
1009/09/2023
1109/09/2023
Data
Cell Formulas
RangeFormula
B8:B11B8=TOCOL(IF(ISNUMBER(SEARCH(" "&A8&" "," "&B1:D5&" ")),A1:A5,1/0),2)
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCD
105/09/2023AppleBananaBanana
206/09/2023BananaGrapeMango and Banana
307/09/2023OrangeAppleWatermelon
408/09/2023GrapeBananaMango
509/09/2023MangoMangoApple
6
7
8Mango06/09/2023
908/09/2023
1009/09/2023
1109/09/2023
Data
Cell Formulas
RangeFormula
B8:B11B8=TOCOL(IF(ISNUMBER(SEARCH(" "&A8&" "," "&B1:D5&" ")),A1:A5,1/0),2)
Dynamic array formulas.
Hi @Fluff, thanks for replying, this would work for the string search but it returns multiple results for 9/9/23. Is there anyway to incorporate the UNIQUE/FILTER function that shift-del did in their reply so that we only get one result returned for 9/9/23?
 
Upvote 0
Yup, you can use
Excel Formula:
=UNIQUE(TOCOL(IF(ISNUMBER(SEARCH(" "&A8&" "," "&B1:D5&" ")),A1:A5,1/0),2))
 
Upvote 0
Hi,

Thanks for the help so far, been great. I have a follow up query, I have some data that looks like this:

5/9/23AppleBananaBanana
6/9/23BananaGrapeGrape
7/9/23OrangeApple x2Watermelon
8/9/23GrapeBananaMango
9/9/23MangoMangoApple x3

So I am currently using @Fluff's formula to find the search word and it returns the 3 dates. Is it possible to get it to also look at the 'x2' or 'x3' within the cell and give the date that many times. So for example if searching for 'Apple' in this table it would return:

5/9/23
7/9/23
7/9/23
9/9/23
9/9/23
9/9/23

I have a formula that gets it to look and pull out the number from the cell but don't know how to get it to duplicate the result that many times. Thanks!
 
Upvote 0
As this is a significantly different question, it needs a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

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