Request for help - If word exists in one column, update another column

Kyote

New Member
Joined
Apr 5, 2010
Messages
5
Howdy all :)

I was hoping someone would be able to help me. With help from this board, I was able to create a formula that displayed one of 3 conditions based on comparing columns. I am looking to do something similar finding text in a single column and updating a different column based on what it finds.

I tried adapting the formula, but it looks far too complex for me and I am thinking it's more appropriate in a macro. So what I am looking to do is to look at Column A's cell contents for many possible words and update the corresponding Column D cells.

So it looks for "apple", "orange", or "pear" and if found it updates with "yummy apples", "lots of oranges", "we gots pears", or blank.

__A_________________D_____
apple__________yummy apples
orange_________lots of oranges
apples here_____yummy apples
I hate pears_____we gots pears
watermelon_____
kiwi____________
candy apples____yummy apples


- If A1 contains "apple", it sets the contents of D1 to "yummy apples"
- If A2 contains "orange", it sets the contents of D2 to "lots of oranges"
- If A5 contains none of the words, it sets D5 blank.
- If A7 contains "candy apple", it sets the contents of D7 to "yummy apples"
- Etc


I had started with a simple formula (below), but I couldn't think of a good way to nest one into another into another without a big confusing mess. I thought rewriting as a macro, looping per line, would be easier. But beyond the basic conditional If Then, I don't know how to find or update in this way.

=IF(ISERROR(FIND("apple",A1, 1)), "", "yummy apples")

If anyone has a moment and a suggestion, I'd appreciate it!

-Kyote
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Howdy all :)

I was hoping someone would be able to help me. With help from this board, I was able to create a formula that displayed one of 3 conditions based on comparing columns. I am looking to do something similar finding text in a single column and updating a different column based on what it finds.

I tried adapting the formula, but it looks far too complex for me and I am thinking it's more appropriate in a macro. So what I am looking to do is to look at Column A's cell contents for many possible words and update the corresponding Column D cells.

So it looks for "apple", "orange", or "pear" and if found it updates with "yummy apples", "lots of oranges", "we gots pears", or blank.

__A_________________D_____
apple__________yummy apples
orange_________lots of oranges
apples here_____yummy apples
I hate pears_____we gots pears
watermelon_____
kiwi____________
candy apples____yummy apples


- If A1 contains "apple", it sets the contents of D1 to "yummy apples"
- If A2 contains "orange", it sets the contents of D2 to "lots of oranges"
- If A5 contains none of the words, it sets D5 blank.
- If A7 contains "candy apple", it sets the contents of D7 to "yummy apples"
- Etc


I had started with a simple formula (below), but I couldn't think of a good way to nest one into another into another without a big confusing mess. I thought rewriting as a macro, looping per line, would be easier. But beyond the basic conditional If Then, I don't know how to find or update in this way.

=IF(ISERROR(FIND("apple",A1, 1)), "", "yummy apples")

If anyone has a moment and a suggestion, I'd appreciate it!

-Kyote
Try this...

Create this 2 column table:

Sheet1

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Verdana,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=0><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 72px"><COL style="WIDTH: 107px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD> </TD><TD>F</TD><TD>G</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid">Apple</TD><TD style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">yummy apples</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">Orange</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">lots of oranges</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">Pear</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">we gots pears</TD></TR></TBODY></TABLE>


A1 = some string like I hate pears

Enter this formula in B1:

=LOOKUP("zzzzz",CHOOSE({1,2},"",LOOKUP(1E100,SEARCH(F1:F3,A1),G1:G3)))

Note that if an entry contains more than one keyword the formula will match the keyword that is furthest down in the table list of keywords.
 
Upvote 0
Try this...

Create this 2 column table:

Sheet1

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Verdana,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=0><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 72px"><COL style="WIDTH: 107px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>F</TD><TD>G</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid">Apple</TD><TD style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">yummy apples</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">Orange</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">lots of oranges</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">Pear</TD><TD style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #000000 1px solid; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-BOTTOM: #000000 1px solid">we gots pears</TD></TR></TBODY></TABLE>


A1 = some string like I hate pears

Enter this formula in B1:

=LOOKUP("zzzzz",CHOOSE({1,2},"",LOOKUP(1E100,SEARCH(F1:F3,A1),G1:G3)))

Note that if an entry contains more than one keyword the formula will match the keyword that is furthest down in the table list of keywords.
If you're using Excel 2007 or later then we can reduce the formula to:

=IFERROR(LOOKUP(1E100,SEARCH(F1:F3,A1),G1:G3),"")
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,258
Members
452,901
Latest member
LisaGo

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