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

Name
Group Name
Should Be
Search For
Return Value
Marvel (V) Ltd
Tom
(V)
Tom
Dr Strange (V) (C) Ltd
Tom
[C]
Harry
Black Panther [C] (C) Ltd
Harry
(C)
Mary
Spiderman (C) Ltd
Mary

<tbody>
</tbody>

Your help would be greatly appreciated.

Kind Regards

Biz
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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
1NameGroup NameShould BeSearch ForReturn Value
2Marvel (V) LtdTomTom(V)Tom
3Dr Strange (V) (C) LtdTomTom[C]Harry
4Black Panther [C] (C) LtdHarryHarry(C)Mary
5Spiderman (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>
</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
1NameGroup NameShould BeSearch ForReturn Value
2Marvel (V) LtdTomTom(V)Tom
3Dr Strange (V) (C) LtdTomTom[CKL]Harry
4Black Panther [CKL] (C) LtdHarryHarry(C)Mary
5Spiderman (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>
</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.

Black Panther [C] (C) LtdHarry
Black Panther (C) [C] Ltd Mary
<colgroup><col width="154" style="width: 116pt; mso-width-source: userset; mso-width-alt: 5489;"> <col width="64" style="width: 48pt;"> <tbody> </tbody>

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,215,131
Messages
6,123,222
Members
449,091
Latest member
jeremy_bp001

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