If formula, with a twist

HeRoseInThree

Board Regular
Joined
Jan 11, 2018
Messages
103
I have an if formula that has a variable. I'd like to search for a keyword (diesel) and if it is found, return a string. I thought about IF(F23="*diesel",S$33 but that didn't work.

Any ideas?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this:
Excel Formula:
=IF(ISNUMBER(SEARCH("diesel",F23)),S$33,"")
 
Upvote 0
Solution
Thank you!!!

The scary thing is, I'm the go to person in my office for all things Excel. You are making me look good!
 
Upvote 0
You are welcome!

The key with that formula is that the "SEARCH" function returns the character where that word starts in the string.
If it is found, it returns a numbers If it is not found, it returns an error.
So we can use the ISNUMBER function to determine if it is found or not.
 
Upvote 0
Follow-up question. How would I connect multiples of these together?

This isn't working:
=IF(ISNUMBER(SEARCH("storage",A19)),B$19,IF(ISNUMBER(SEARCH("tow",A19)),B$19))
 
Upvote 0
Maybe this way
Excel Formula:
=IF(OR(ISNUMBER(SEARCH("storage",A19)),ISNUMBER(SEARCH("tow",A19))),B19,"")
 
Upvote 0
Hi,

You can also try this:

Book3.xlsx
ABC
19towcakecake
20tree 
21storagecake
22tree towcake
23flower storagecake
24flower tow treecake
Sheet753
Cell Formulas
RangeFormula
C19:C24C19=IF(SUM(COUNTIF(A19,{"*storage*","*tow*"})),B$19,"")
 
Upvote 0
Too late to edit.

Please note, you can add as many Keywords as you want inside the curly brackets to my formula in Post #7.
 
Upvote 0
Hi,

You can also try this:

Book3.xlsx
ABC
19towcakecake
20tree 
21storagecake
22tree towcake
23flower storagecake
24flower tow treecake
Sheet753
Cell Formulas
RangeFormula
C19:C24C19=IF(SUM(COUNTIF(A19,{"*storage*","*tow*"})),B$19,"")
I am not trying to count the number of times the word occurs, just whatever is in the B column if the word is in the A column.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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