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?
 
Is this what you mean
+Fluff 1.xlsm
ABC
19towAA
20treeB 
21storageCC
22tow storageDD
23flower storeE 
24flower tow treeFF
Master
Cell Formulas
RangeFormula
C19:C24C19=IF(SUM(COUNTIF(A19,{"*storage*","*tow*"})),B19,"")
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
=IF(OR(ISNUMBER(SEARCH("storage",A19)),ISNUMBER(SEARCH("tow",A19))),B19,"")
This works for the first search word, not the second...

I need to put a word into a19 (let's say tow)
then in b19, a dollar amount for the tow. 1000

What I'd like to happen is for Excel to know that this is a tow bill and that it cost $1,000 as opposed to storage charges for 500 which will be entered in another cell...
 
Upvote 0
Maybe
Excel Formula:
=IF(ISNUMBER(SEARCH("storage",A19)),500,IF(ISNUMBER(SEARCH("tow",A19)),1000,""))
If that doesn't work please post some sample data showing expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
N&I - BLANK - repair bill - ESTIMATE.xlsx
ABCDEFGHIJKL
19storage4555Storage fees$4,555.00
20inspectInspect to determine necessary repairs$131.25
21tow555Towing$4,555.00
Sheet1
Cell Formulas
RangeFormula
E19:E21E19=IF(ISBLANK(A19),"",IF(A19="tow","Towing",IF(A19="etow","Emergency roadside towing",IF(A19="itow","In house towing",IF(A19="inspect","Inspect to determine necessary repairs",IF(A19="storage","Storage fees",IF(A19="scene","Clean up at scene",IF(A19="prop","Other real property damaged",IF(A19="wc","Subrogation for W/C injury",IF(A19="gas","Diesel fuel",IF(A19="parts","misc parts",IF(A19="ship","Shipping for parts",IF(A19="cool","Reclaim refrigerant, replace and perform leak check",IF(A19="fea","Front end alignment",IF(A19="h20","12 gallons of antifreeze @ $6.73",IF(A19="bodyp","Body shop (parts & materials)",IF(A19="bodyl","Body shop (labor)",IF(A19="misc","Misc shop procedures, supplies & administrative fees",IF(A19="af","Antifreeze", IF(A19="report","Purchase accident report",0))))))))))))))))))))
L19:L21L19=IF(ISBLANK(A19),"",IF(E19="Towing",R$9,IF(E19="In house towing",R$14,IF(E19="itow","In house towing",IF(E19="Storage fees",R$25,IF(ISNUMBER(SEARCH("diesel",E19)),R$34,IF(E19="Inspect to determine necessary repairs",R$29,IF(E19="Storage fees",R$24,IF(E19="Body shop (labor)",R$22,IF(E19="Body shop (parts & materials)",T$20,IF(E19="Front end alignment","$412.78",IF(E19="Antifreeze ",T$34,IF(E19="misc parts",O$11,IF(E19="Shipping for parts",T$28, IF(E19="Misc shop procedures, supplies & administrative fees",Sheet2!B$1,0)))))))))))))))
 
Upvote 0
So what's your question? You already seem to have something that works.
 
Upvote 0
I need to put a word into a19 (let's say tow)
then in b19, a dollar amount for the tow. 1000

What I'd like to happen is for Excel to know that this is a tow bill and that it cost $1,000 as opposed to storage charges for 500 which will be entered in another cell...
 
Upvote 0
N&I - BLANK - repair bill - ESTIMATE.xlsx
QRSTU
7
8outside towing
9$4,555.00
10
11in house towing
126.5
13$250.00
14$1,625.00
15
16Body shop - laborBody shop - parts
175.21$1,202.72
18$0.73
19$521.00
205.21$1,724.45
21$85.00
22$442.85steering fluid
234
24storage fees$4.34
25$4,555.00$17.36
26
27inspection hoursshipping
281.25$824.00
29$131.25
30
31fuel gallonsAntifreeze
3211015
33$2.87$6.73
34$315.70$100.95
35
Sheet1
Cell Formulas
RangeFormula
R9R9=IF(OR(ISNUMBER(SEARCH("storage",A19)),ISNUMBER(SEARCH("tow",A19))),B19,"")
R14,T34,R34,R22R14=R12*R13
R20R20=SUM(R17:R19)
T20T20=IF(ISBLANK(T17),"",SUM(T17:T19))
R25R25=IF(SUM(COUNTIF(A19,{"*storage*","*tow*"})),B$19,"")
T25T25=T24*T23
R29R29=R28*C45
Cells with Conditional Formatting
CellConditionCell FormatStop If True
T31:T33Cell Value=0textNO
R25:R33Cell Value=0textNO
 
Upvote 0
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.

Did you look at my sample in Post #7 ?

The COUNTIF statement mimics the SEARCH function in my formula, the result was B19 = cake, Not a count of the words "tow" or "storage", the COUNTIF found the keywords and output whatever is in B19, which can be your Dollar amount for the charge.
And it seems to do what you described, in your post # 17 cell R25
 
Last edited:
Upvote 0
What I'd like to happen is for Excel to know that this is a tow bill and that it cost $1,000 as opposed to storage charges for 500 which will be entered in another cell...
Isn't that what the formula in post#13 does?
 
Upvote 0
Exact same formula as in my Post # 7, and as I said in Post # 8, you can include as many Keywords inside the curly brackets as you want.

If it helps you see it more clearly, I've changed "cake" to $1,500.00

Book3.xlsx
ABC
19tow$1,500.00$1,500.00
20tree 
21Storage$1,500.00
22tree Tow$1,500.00
23flower storage$1,500.00
24flower tow tree$1,500.00
Sheet753
Cell Formulas
RangeFormula
C19:C24C19=IF(SUM(COUNTIF(A19,{"*storage*","*tow*"})),B$19,"")
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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