Lookup: If a cell contains a string, return a value from an array

aumabrey

New Member
Joined
Jan 24, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. MacOS
I'm curious about the best way to search a cell, and if a specific string is found then return a specific value based on an array of outputs. Here's the current formula that I'm trying and I'm not sure what the issue is (I'm on Excel 2019 for Mac if that is a potential issue):

=INDEX($D$2:$D$5,MATCH(TRUE,ISNUMBER(SEARCH($C$2:$C$5,A2)),0))

Screen Shot 2022-01-24 at 4.02.50 PM.png


Basically, I would like to search through A1, if a value from column C is found, the return the corresponding value from Column D into column B.

This is my first post, so hopefully I didn't break any rules or guidelines too horrendously, and apologies if I missed anything.

Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the MrExcel forum!

Try:

Book2
ABCD
1SampleOutputKeyOutput Array
2Red wine on the carpetFound RedRedFound Red
3Blue -like the color or the moodFound BlueBlueFound Blue
4yellow -testing if capitalization mattersno matchYellowFound Yellow
5xxgreenxx if the string needs to be isolated by whitespace or delimitersno matchGreenFound Green
6RedFound Red
7BlueFound Blue
8GreenFound Green
9YellowFound Yellow
10
Sheet14
Cell Formulas
RangeFormula
B2:B9B2=IFERROR(LOOKUP(2,1/FIND(" "&$C$2:$C$5&" "," "&A2&" "),$D$2:$D$5),"no match")


If you DON'T want capitalization to matter, use SEARCH instead of FIND.
 
Upvote 0
Solution
Welcome to the MrExcel forum!

Try:

Book2
ABCD
1SampleOutputKeyOutput Array
2Red wine on the carpetFound RedRedFound Red
3Blue -like the color or the moodFound BlueBlueFound Blue
4yellow -testing if capitalization mattersno matchYellowFound Yellow
5xxgreenxx if the string needs to be isolated by whitespace or delimitersno matchGreenFound Green
6RedFound Red
7BlueFound Blue
8GreenFound Green
9YellowFound Yellow
10
Sheet14
Cell Formulas
RangeFormula
B2:B9B2=IFERROR(LOOKUP(2,1/FIND(" "&$C$2:$C$5&" "," "&A2&" "),$D$2:$D$5),"no match")


If you DON'T want capitalization to matter, use SEARCH instead of FIND.
Thanks Eric!

This is a good thought, unfortunately the data isn't always consistent with delimiters.... For example some months it may be "Blue - like the..." others it may be "Blue-like the..."

=IFERROR(LOOKUP(2,1/SEARCH($C$2:$C$5,A2),$D$2:$D$5),"no match")
I modified it to this to remove the leading and trailing whitespace, but this was a an immense help! Thanks for the speedy solution!!!
 
Upvote 0
Just found this message board - thanks so much for the answer here @EricW! A huge help.
 
Upvote 0
Welcome to the MrExcel forum!

Try:

Book2
ABCD
1SampleOutputKeyOutput Array
2Red wine on the carpetFound RedRedFound Red
3Blue -like the color or the moodFound BlueBlueFound Blue
4yellow -testing if capitalization mattersno matchYellowFound Yellow
5xxgreenxx if the string needs to be isolated by whitespace or delimitersno matchGreenFound Green
6RedFound Red
7BlueFound Blue
8GreenFound Green
9YellowFound Yellow
10
Sheet14
Cell Formulas
RangeFormula
B2:B9B2=IFERROR(LOOKUP(2,1/FIND(" "&$C$2:$C$5&" "," "&A2&" "),$D$2:$D$5),"no match")


If you DON'T want capitalization to matter, use SEARCH instead of FIND.
@Eric W What if the red, blue, yellow or green in column A are not in the beginning of the string but are somewhere in the middle of the string? Thank you.
PS Sorry, found out what I was doing wrong.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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