Excel Multiple Search and return Non Array formula

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Hi,
I have difficult question which I need non array formula in column B which looks at column A reference uses wildcard match Column an returns vales from Column E.


Column A Column B Column C Column D Column E

[TABLE="width: 370"]
<tbody>[TR]
[TD="width: 150, bgcolor: transparent"]Name
[/TD]
[TD="width: 82, bgcolor: transparent"]Group Name
[/TD]
[TD="width: 64, bgcolor: transparent"]Should Be
[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 69, bgcolor: transparent"]Search For
[/TD]
[TD="width: 64, bgcolor: transparent"]Return Value
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Marvel (V) Ltd
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]Tom
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"](V)
[/TD]
[TD="bgcolor: transparent"]Tom
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Dr Strange (V) (C) Ltd
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]Tom
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][C]
[/TD]
[TD="bgcolor: transparent"]Harry
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Black Panther [C] (C) Ltd
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]Harry
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"](C)
[/TD]
[TD="bgcolor: transparent"]Mary
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Spiderman (C) Ltd
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]Mary
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]

Your help would be greatly appreciated.

Kind Regards

Biz
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Why do you specify a non array formula? Surely any formula that performs the task efficiently should be acceptable?

Anyway, ..

IF your sample data is representative in that all 'Search For' items are 3 characters long you could try this - no sorting required.

Group Name (1)

ABCDE
NameGroup NameShould BeSearch ForReturn Value
Marvel (V) LtdTomTom(V)Tom
Dr Strange (V) (C) LtdTomTom[C]Harry
Black Panther [C] (C) LtdHarryHarry(C)Mary
Spiderman (C) LtdMaryMary

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 169px;"><col style="width: 93px;"><col style="width: 79px;"><col style="width: 83px;"><col style="width: 95px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]4[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]5[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
B2=VLOOKUP(MID(A2,AGGREGATE(15,6,SEARCH(D$2:D$4,A2),1),3),D$2:E$4,2,0)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


IF your sample data is representative in that all 'Search For' items are enclosed in () or [] then you could try this.

Group Name (2)

ABCDE
NameGroup NameShould BeSearch ForReturn Value
Marvel (V) LtdTomTom(V)Tom
Dr Strange (V) (C) LtdTomTom[CKL]Harry
Black Panther [CKL] (C) LtdHarryHarry(C)Mary
Spiderman (C) [CKL] LtdMaryMary

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 185px;"><col style="width: 93px;"><col style="width: 79px;"><col style="width: 83px;"><col style="width: 95px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]4[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]5[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
B2=VLOOKUP(TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"[","#["),"]","]#"),"(","#("),")",")#"),"#",REPT(" ",100)),100,100)),D$2:E$4,2,0)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Can't use an array formula as people I'm setting up formluas don't like it.
I like Group Name 1 formula with aggregate formula is awesome.

Thank you for your help too.
 
Upvote 0
That's right. Sort D:E together, ascending on D.
Ahh, now that matches your screen shot from post 5, whereas your description then didn't :)
Sort D:E in ascending order on column E...


Thank you vey much, it works as desired.
In that case I must have misunderstood what you meant by "get the first match" in post 3. I thought you meant the first match in the column A value but you must have meant the first match in the column D values. Is that correct? Just to confirm, should both of these give "Harry" as the result?
Black Panther [C] (C) Ltd
Black Panther (C) [C] Ltd
 
Upvote 0
Ahh, now that matches your screen shot from post 5, whereas your description then didn't :)


In that case I must have misunderstood what you meant by "get the first match" in post 3. I thought you meant the first match in the column A value but you must have meant the first match in the column D values. Is that correct? Just to confirm, should both of these give "Harry" as the result?
Black Panther [C] (C) Ltd
Black Panther (C) [C] Ltd

Hi M8,

Your formula with Vlookup with AGGREGATE function derives the results which fit my case.

[TABLE="width: 164"]
<colgroup><col width="154" style="width: 116pt; mso-width-source: userset; mso-width-alt: 5489;"> <col width="64" style="width: 48pt;"> <tbody>[TR]
[TD="width: 154, bgcolor: transparent"]Black Panther [C] (C) Ltd[/TD]
[TD="width: 64, bgcolor: #C6E0B4"]Harry[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Black Panther (C) [C] Ltd [/TD]
[TD="width: 64, bgcolor: #C6E0B4"]Mary[/TD]
[/TR]
</tbody>[/TABLE]

Thank you very much.

Kind Regards

Biz
 
Upvote 0
Thank you vey much, it works as desired.
Your formula with Vlookup with AGGREGATE function derives the results which fit my case.
The two above statements cannot both be true.

Excel Workbook
ABDE
1NameGroup NameSearch ForReturn Value
2Marvel (V) LtdTom(C)Mary
3Dr Strange (V) (C) LtdTom(V)Tom
4Black Panther [C] (C) LtdHarry[C]Harry
5Black Panther (C) [C] LtdHarry
Group Name (Post 5)


Excel Workbook
ABDE
1NameGroup Name Post 9Search ForReturn Value
2Marvel (V) LtdTom(V)Tom
3Dr Strange (V) (C) LtdTom[C]Harry
4Black Panther [C] (C) LtdHarry(C)Mary
5Black Panther (C) [C] LtdMary
Group Name (Post 9)
 
Upvote 0
Hi Peter,

Your Vlookup and Aggregate formula is correct and gives the right result I'mafter.
Thank you for your amazing formula and I spent looking at it and learnt new tricks.

Kind Regards,
Biz
 
Upvote 0
You're welcome. Thanks for the clarification.

BTW, if
- the only () or [] in column A are around the 'Search for' terms, and
- the 'Search for' terms are all exactly 3 characters
then a further simplification is possible

Excel Workbook
ABCDE
1NameGroup NameSearch ForReturn Value
2Marvel (V) LtdTom(V)Tom
3Dr Strange (V) (C) LtdTom[C]Harry
4Black Panther [C] (C) LtdHarry(C)Mary
5Black Panther (C) [C] LtdMary
6Spiderman (C) LtdMary
Group Name (1a)
 
Upvote 0
Awesome streamlined formula. Thank you very much for your help again.
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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