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
 
No it's not. ;)
+Fluff New.xlsm
AB
1Inventory
208/24/2019 H2732-59057 cat ODELLH2732-59057
3I 43 0000-484-403 VIATERA 3CM 1.0 $0.0043
4I 83 0000-282-627 KPI NATIONAL 1.0 $0.0083
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.0059
9R 60 0000-524-891 FASCIA 6 S 1.0 $0.0060
10R 61 0000-677-440 F5.5S CM WH 1.0 $0.0061
11R 62 0000-386-653 QUICKSTRT RL 1.0 $0.0062
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("000",A2)))-FIND(" ",A2)))
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
It worked except for row 7, it returns H2732-610352222. Also, the "000", there are times where when it starts with a 1000. It should be 58
 
Upvote 0
I'm afraid you've lost me. Could you post some more sample data & the expected outcome.
 
Upvote 0
The line number always follows an R and the space before 0000 or 1000. Hope this makes sense

Book1
ABCD
1InventoryOrder #Line #Line # Actual
208/24/2019 H2732-59057 cat ODELLH2732-59057H2732-59057
3I 43 0000-484-403 VIATERA 3CM 1.0 $0.00 43
4I 83 0000-282-627 KPI NATIONAL 1.0 $0.00 83
511/01/2019 H2732-59057 cat ODELL I 124 0000-282-627 KPI NATIONAL 1.0 $0.00H2732-59057H2732-59057
607/17/2019 H2732-59477 cat KEENOY S 0710 0000-867-770 SBSD137HWW 1.0 $0.00H2732-59477H2732-59477
710/28/2019 H2732-610352222 cat HAMMER R 58 0000-787-792 1/2 OSB 4.0 $0.00H2732-610352222H2732-61035222258
8R 59 0000-678-905 SOFFIT V W 1.0 $0.00 5959
9R 60 0000-524-891 FASCIA 6 S 1.0 $0.00 6060
10R 61 0000-677-440 F5.5S CM WH 1.0 $0.00 6161
11R 62 0000-386-653 QUICKSTRT RL 1.0 $0.00 6262
1202/18/2020 W849994803 House Henkel R 1001 1001-382-439W849994803W8499948031001
13R 62 1000-386-653 QUICKSTRT RL 1.0 $0.00 62 162
14
Sheet4
Cell Formulas
RangeFormula
B2:B13B2=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND(" ",A2)))-FIND(" ",A2)))
C2:C13C2=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND("000",A2)))-FIND(" ",A2)))
 
Upvote 0
How about
+Fluff New.xlsm
ABC
1InventoryOrder #Line #
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-61035222258
8R 59 0000-678-905 SOFFIT V W 1.0 $0.00 59
9R 60 0000-524-891 FASCIA 6 S 1.0 $0.00 60
10R 61 0000-677-440 F5.5S CM WH 1.0 $0.00 61
11R 62 0000-386-653 QUICKSTRT RL 1.0 $0.00 62
1202/18/2020 W849994803 House Henkel R 1001 1001-382-439W8499948031001
13R 62 1000-386-653 QUICKSTRT RL 1.0 $0.00 62
Data
Cell Formulas
RangeFormula
B2:B13B2=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND(" ",A2)))-FIND(" ",A2)))
C2:C13C2=IFERROR(MID(A2,FIND(" R "," "&A2)+2,FIND(" ",A2,FIND(" R "," "&A2)+2)-FIND(" R "," " &A2)-2),"")
 
Upvote 0
My pleasure & thanks for the feedback.
 
Upvote 0
Hello,
I wasn’t sure if I needed to start a new post but I have a follow-up question. Earlier in this post, you helped me achieve the results I needed with this formula;

=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),IFERROR(SEARCH("house",A2),FIND(" ",A2)))-FIND(" ",A2)))

I made a slight update as the format of the report changed;

=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),FIND(" ",A2))-FIND(" ",A2)))

This has been working great except, sometimes; there isn’t a space to Find because the string appears in the beginning of the cell as in example, A9.
Is there a way to alter the formula or do I need to add a helper column?

Your help is appreciated.

Book1
AB
1InventoryOrder #
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 
9W848156480 cat Henkel R 1001 1001-382-439 
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 cat Henkel R 1001 1001-382-439W849994803
13R 62 1000-386-653 QUICKSTRT RL 1.0 $0.00 
Sheet5
Cell Formulas
RangeFormula
B2:B13B2=TRIM(MID(A2,FIND(" ",A2),IFERROR(SEARCH("cat",A2),FIND(" ",A2))-FIND(" ",A2)))
 
Upvote 0
How about
=TRIM(RIGHT(SUBSTITUTE(REPLACE(A2,IFERROR(SEARCH("cat",A2)-1,1),100,"")," ",REPT(" ",100)),100))
 
Upvote 0

Forum statistics

Threads
1,215,548
Messages
6,125,468
Members
449,230
Latest member
ASBeard

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