Extract 2 word street names

duteberta

Board Regular
Joined
Jun 14, 2009
Messages
92
Office Version
  1. 365
Platform
  1. MacOS
Given the cell A1 with the contents being "5519 Old Barn Dr."

What formula would get just "Old Barn"?

I have tried other formulas such as
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",200)),200,(1*(MIN(IFERROR(FIND({" NW "," NE "," SW "," SE "," N "," E "," W "," S "},A1),100))<100)+1)*200))

But all I get is "Old".

But I cannot find just 1 formula to rule satisfy most all street addresses. The above formula does not take into consideration two-word street names.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you don't mind using VBA.

EXCEL
AB
15519 Old Barn Dr.Old Barn
224541 Greer River LaneGreer River
313464 Purple Mustard Ct.Purple Mustard
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=TWOWORDS(A1)


VBA Code:
Function TWOWORDS(s As String)
With CreateObject("VBScript.RegExp")
    .Pattern = "\d+\s((\w+\s?){2})\s"
    TWOWORDS = .Execute(s)(0).submatches(0)
End With
End Function
 
Upvote 0
If you didn't want a VBA option, then perhaps this might work? I don't know what version of Excel you have so both 365 & pre 365 options given.
Book1
ABC
1Address365pre 365
244 Wood LaneWoodWood
35519 Old Barn Dr.Old BarnOld Barn
412 Sir Donald Bradman DriveSir Donald BradmanSir Donald Bradman
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=TEXTAFTER(TEXTBEFORE(A2," ",-1)," ",1)
C2:C4C2=TRIM(MID(LEFT(A2,FIND("/", SUBSTITUTE(A2," ","/", LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))-1),FIND(" ",A2,1)+1,100))
 
Upvote 0
In hindsight, you don't really need the Trim:
Book1
ABC
1Address365pre 365
244 Wood LaneWoodWood
35519 Old Barn Dr.Old BarnOld Barn
412 Sir Donald Bradman DriveSir Donald BradmanSir Donald Bradman
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=TEXTAFTER(TEXTBEFORE(A2," ",-1)," ",1)
C2:C4C2=MID(LEFT(A2,FIND("/", SUBSTITUTE(A2," ","/", LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))-1),FIND(" ",A2,1)+1,100)
 
Upvote 0
LOVE IT- thank you!
Glad you got a successful outcome. It would still assist your helpers in the future if you updated your profile to show your Excel version as @kevin9999 suggested in post #3. ;)
Click your user name at the top right of the forum, then ‘Account details’. After adjusting, don’t forget to scroll down & ‘Save’.
 
Upvote 0
Glad you got a successful outcome. It would still assist your helpers in the future if you updated your profile to show your Excel version as @kevin9999 suggested in post #3. ;)
Click your user name at the top right of the forum, then ‘Account details’. After adjusting, don’t forget to scroll down & ‘Save’.
Ok will do now
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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