Search with a cell to find text and then do a vlookup

legendary_popsicle

New Member
Joined
Jul 25, 2011
Messages
49
I am a longtime lurker for work-related questions. I can usually find what I need, but now I finally have a question where I feel the need to register and post. :biggrin:

Unfortunately, I deal with a lot of dirty data at work. What I need is a formula that can look within text and return what the user really meant to type. Then I would like to be able to do a vlookup with that value.

Example:

A1: Crapples
A2: Carrots
A3: /Milk

B1: FORMULA (see below)

C1: Apple ; D1: Fruit
C2: Carrot ; D2: Veggie
C3: Milk ; D3: Dairy

I want there to be a formula to look in the range C1:C3 and see if any of those words are in the cell A1. If it is, perform a vlookup in the C1:D3 using the value that was found in the cell.

I've gotten to the point where I have a formula (listed below) that tells me whether or not a word from that range is in the cell, but I can't get to the vlookup portion. Let me know if you guys can help!

=IF(ISNUMBER(LOOKUP(9E+99+307,(SEARCH($C$1:$C$3,A1)))),"Food","Other")
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I am a longtime lurker for work-related questions. I can usually find what I need, but now I finally have a question where I feel the need to register and post. :biggrin:

Unfortunately, I deal with a lot of dirty data at work. What I need is a formula that can look within text and return what the user really meant to type. Then I would like to be able to do a vlookup with that value.

Example:

A1: Crapples
A2: Carrots
A3: /Milk

B1: FORMULA (see below)

C1: Apple ; D1: Fruit
C2: Carrot ; D2: Veggie
C3: Milk ; D3: Dairy

I want there to be a formula to look in the range C1:C3 and see if any of those words are in the cell A1. If it is, perform a vlookup in the C1:D3 using the value that was found in the cell.

I've gotten to the point where I have a formula (listed below) that tells me whether or not a word from that range is in the cell, but I can't get to the vlookup portion. Let me know if you guys can help!

=IF(ISNUMBER(LOOKUP(9E+99+307,(SEARCH($C$1:$C$3,A1)))),"Food","Other")
You're pretty close.

Try this...

=LOOKUP(1E100,SEARCH(C$1:C$3,A1),D$1:D$3)
 
Upvote 0
Is there a way to make this formula variable so that if I manually add names to the Food Table then I won't have to change the range in the formula?
 
Upvote 0
Is there a way to make this formula variable so that if I manually add names to the Food Table then I won't have to change the range in the formula?
You can create a dynamic range that refers to the lookup table.

Name: Table (or whatever)
Refers to: =$C$1:INDEX($D:$D,MATCH("zzzzz",$C:$C))

Then the lookup formula becomes:

=LOOKUP(1E100,SEARCH(INDEX(Table,,1),A1),INDEX(Table,,2))
 
Upvote 0
You can create a dynamic range that refers to the lookup table.

Name: Table (or whatever)
Refers to: =$C$1:INDEX($D:$D,MATCH("zzzzz",$C:$C))

Then the lookup formula becomes:

=LOOKUP(1E100,SEARCH(INDEX(Table,,1),A1),INDEX(Table,,2))

This one doesn't seem to be working...
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

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