Combining formula on three conditions

rex759

Well-known Member
Joined
Nov 8, 2004
Messages
608
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am having trouble combining these two formulas into one. I thought I could use something like this:

=IF(ISERROR(REPLACE(LEFT(A85,FIND(" ",A85,FIND("CAT",A85)+1)-4),1,FIND(" ",A85),"")),REPLACE(LEFT(A85,FIND(" ",A85,FIND("HOUSE",A85)+1)-6),1,FIND(" ",A85),""),REPLACE(LEFT(A85,FIND(" ",A85,FIND("CAT",A85)+1)-4),1,FIND(" ",A85),""))

But when I do, it only works correctly when the string “CAT” is found. There are three options:
If A85 has Cat, House, or neither.

Any help is appreciated
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Can you please post some sample data, along with expected results using the XL2BB add-in?
 
Upvote 0
Thank you for replying. I deleted a bunch of lines on the spreadsheet to make it easier to read so the ranges are not the same in my original post.

Book1
AB
1Inventory
208/24/2019 H2732-59057 cat ODELLH2732-59057
3I 43 0000-484-403 VIATERA 3CM 1.0 $0.00 
4I 83 0000-282-627 KPI NATIONAL 1.0 $0.00 
511/01/2019 H2732-59057 cat ODELL I 124 0000-282-627 KPI NATIONAL 1.0 $0.00H2732-59057
607/17/2019 H2732-59477 cat KEENOY S 0710 0000-867-770 SBSD137HWW 1.0 $0.00H2732-59477
710/28/2019 H2732-610352222 cat HAMMER R 58 0000-787-792 1/2 OSB 4.0 $0.00H2732-610352222
8R 59 0000-678-905 SOFFIT V W 1.0 $0.00 
9R 60 0000-524-891 FASCIA 6 S 1.0 $0.00 
10R 61 0000-677-440 F5.5S CM WH 1.0 $0.00 
11R 62 0000-386-653 QUICKSTRT RL 1.0 $0.00 
1202/18/2020 W849994803 house Henkel R 1001 1001-382-439W849994803
13
Sheet1
Cell Formulas
RangeFormula
B2:B11B2=IFERROR(REPLACE(LEFT(A2,FIND(" ",A2,FIND("cat",A2)+1)-4),1,FIND(" ",A2),""),"")
B12B12=REPLACE(LEFT(A12,FIND(" ",A12,FIND("house",A12)+1)-6),1,FIND(" ",A12),"")
 
Upvote 0
Thanks for that, how about
+Fluff New.xlsm
AB
1Inventory
208/24/2019 H2732-59057 cat ODELLH2732-59057
3I 43 0000-484-403 VIATERA 3CM 1.0 $0.00 
4I 83 0000-282-627 KPI NATIONAL 1.0 $0.00 
511/01/2019 H2732-59057 cat ODELL I 124 0000-282-627 KPI NATIONAL 1.0 $0.00H2732-59057
607/17/2019 H2732-59477 cat KEENOY S 0710 0000-867-770 SBSD137HWW 1.0 $0.00H2732-59477
710/28/2019 H2732-610352222 cat HAMMER R 58 0000-787-792 1/2 OSB 4.0 $0.00H2732-610352222
8R 59 0000-678-905 SOFFIT V W 1.0 $0.00 
9R 60 0000-524-891 FASCIA 6 S 1.0 $0.00 
10R 61 0000-677-440 F5.5S CM WH 1.0 $0.00 
11R 62 0000-386-653 QUICKSTRT RL 1.0 $0.00 
1202/18/2020 W849994803 house Henkel R 1001 1001-382-439W849994803
Data
Cell Formulas
RangeFormula
B2:B12B2=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND(" ",A2)))-FIND(" ",A2)))
 
Upvote 0
Stepped out for a bit but will check when I get back. Looks much cleaner then mine!
 
Upvote 0
Yes, it works perfectly. Thank you very much.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Can I ask one more question? I want to extract the number that falls between an R and the space before the 0000s. For example, in row 8, R 59 000-678-905 SOFFIT V W 1.0 $0.00, I want to extract the 59. In row 9, extract the 60 and so on. I was trying to incorporate Search and Find but cannot do it in one formula.
 
Upvote 0
How about
=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND("000",A2)))-FIND(" ",A2)))
 
Upvote 0

Forum statistics

Threads
1,216,107
Messages
6,128,869
Members
449,475
Latest member
Parik11

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