Vlookup & Search - Multiple values to look up and enter

Steve2020

New Member
Joined
Oct 9, 2017
Messages
2
Hi,

This is the formula I am currently using in the top right most cell in the table below showing "Melbourne":

(Look at the 3rd column and see if it contains "MEL", if it does then return value in column 2)

=VLOOKUP(MID(D2,SEARCH("MEL",D2),3),$B$2:$C$9,2,FALSE)

(Lookup table is the first 2 columns, 3rd column is the value lookedup, 4th column contains the formula above):
ADLAdelaidezzzzzz_MEL_jjjjj_1000Melbourne
BNEBrisbanezzzzzz_MEL_jjjjj_1000Melbourne
CAIRNSCairnszzzzzz_PER_jjjjj_1000#VALUE!
CBRCanberrazzzzzz_PER_jjjjj_1000#VALUE!
DRWDarwinzzzzzz_SYD_jjjjj_1000#VALUE!
MELMelbournezzzzzz_SYD_jjjjj_1000#VALUE!
PERPerthyyy_ADL_jjjjj_1000#VALUE!
SYDSydneyyyy_ADL_jjjjj_1000#VALUE!

<tbody>
</tbody>

<tbody>
</tbody>

What I'd like to do is have the Search function include PER, SYD, etc. so that it will look up the rest of the cities, and not just MEL which is the current state of the formula.

Would anyone be able to help out here please? :)
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Someone may have a better way, but I'll share my solution anyway! It uses INDEX rather than VLOOKUP.
If you number each of your search criteria as I have below, you can then use the following formula starting in cell F2 and filling down to do what you're after. I've added a couple more rows to show the lookup table (B:D) is separate to the data table (E:F):
{=INDEX($D$2:$D$9,MAX(IF(ISNUMBER(SEARCH($C$2:$C$9,E2)),$B$2:$B$9)))}

Note this is an array formula and requires control+shift+enter to work

ABCDEFG
1
21ADLAdelaidezzzzzz_MEL_jjjjj_1000Melbourne
32BNEBrisbanezzzzzz_MEL_jjjjj_1000Melbourne
43CAIRNSCairnszzzzzz_PER_jjjjj_1000Perth
54CBRCanberrazzzzzz_PER_jjjjj_1000Perth
65DRWDarwinzzzzzz_SYD_jjjjj_1000Sydney
76MELMelbournezzzzzz_SYD_jjjjj_1000Sydney
87PERPerthyyy_ADL_jjjjj_1000Adelaide
98SYDSydneyyyy_ADL_jjjjj_1000Adelaide
10yyy_ADL_jjjjj_1000Adelaide
11yyy_SYD_jjjjj_1000Sydney
12yyy_CAIRNS_jjjjj_1000Cairns
13yyy_ADL_jjjjj_1000Adelaide
14

<tbody>
</tbody>
 
Upvote 0
In D1 enter and copy down:

=IFERROR(LOOKUP(9.99999999999999E+307,SEARCH("_"&$A$1:$A$8&"_",$C1),$B$1:$B$8),"")
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,575
Members
449,089
Latest member
Motoracer88

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