Easy? Remove "St., Rd., or Ave" Suffix from address

jeffcoleky

Active Member
Joined
May 24, 2011
Messages
274
I'm trying to remove the suffix in some addresses so that it only reads the first part of the street address.

The catch is that sometimes there is a ZIPCODE in the same field and sometimes there is not. Also, sometimes it reads "Ave, Rd. or St." and sometimes "AVENUE, ROAD, STREET".

The wording of the formula might be, "remove the last word from the cell up to the first space unless there is a number also in which case remove the last TWO"

I used this code but if there is more than one word in the address it doesn't extract them both: =LEFT($A2,FIND(" ",$A2,8)-1)

Here's the sample data:
Excel 2010
AB
1Before
Desired Output
21585 SOUTH 15TH STREET 589281585 South 15th
31358 DIXDALE AVENUE 582181358 Dixdale
45815 LAMOND DRIVE5815 Lamond
55325 HAVENTREE PLACE5325 Haventree
65383 WOLF PEN TRACE 588595383 Wolf Pen
75929 BAY HARBOR DRIVE5929 Bay Harbor
82527 WEST BURNETT AVENUE 2527 West Burnett
97985 PICKWICK LANE7985 Pickwick
102815 FARNSLEY ROAD 582132815 Farnsley
112131 SADIEVILLE DRIVE 582172131 Sadieville
125788 VARBLE AVENUE 582115788 Varble
137218 PEPPERMILL DRIVE 582287218 Peppermill

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Is there an easy way to do this?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
The most stable way would be to place words you want to truncate.
For example, "Street", "Avenue"...

Then the formula should look through these words and check with the full address and then remove all the characters after the found word.

However, this may cause a bug if your full address is something like
"1234 Street Lane 11859"
 
Upvote 0
Isn't there a way to search fromt he right for a number, and if found remove it and the word before it, if not found remove the last word?
 
Upvote 0
Probably a WAAAAY shorter way to do it, but this should do the trick -
Code:
=IF(ISNUMBER(--RIGHT(A1,5)),LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1))-1),LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-1))
 
Upvote 0
If your prepared to use some code , this should do the job.
Code:
[COLOR="Navy"]Sub[/COLOR] MG20Jun30
[COLOR="Navy"]Dim[/COLOR] Rdtype      [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng         [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn          [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Wd
[COLOR="Navy"]Dim[/COLOR] Stg         [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] n           [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
Rdtype = "AVENUE/ROAD/LANE/DRIVE/PLACE/TRACE/STREET"
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        Wd = Split(Dn, " ")
    [COLOR="Navy"]For[/COLOR] n = 0 To UBound(Wd)
        [COLOR="Navy"]If[/COLOR] InStr(Rdtype, Wd(n)) > 0 [COLOR="Navy"]Then[/COLOR] [COLOR="Navy"]Exit[/COLOR] For
            Stg = Stg & " " & Wd(n)
        [COLOR="Navy"]Next[/COLOR] n
            Dn.Offset(, 1) = Mid(Stg, 2)
            Stg = ""
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Probably a WAAAAY shorter way to do it, but this should do the trick -
Code:
=IF(ISNUMBER(--RIGHT(A1,5)),LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1))-1),LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-1))



I appreciate all the help from everyone. However, this formula is the closest I've come to a solution. Besides the fact that the formula doesn't work, I'm embedding this formula inside a Vlookup and ISNA formula so a LONG formula is less desirable.

I'd LIKE to avoid code, but will resort to MickG's method if I absolutly have to.

Can anyone take this long one and help me make it work but shorter?

Code:
=IF(ISNUMBER(--RIGHT(A1,5)),LEFT(A1,FIND("?",SUBSTITUTE(A1,"  ","?",LEN(A1)-LEN(SUBSTITUTE(A1,"  ",""))-1))-1),LEFT(A1,FIND("?",SUBSTITUTE(A1,"  ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-1))
 
Last edited:
Upvote 0
Shortened it a bit: =LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-CHOOSE(--ISNUMBER(--RIGHT(A1,5))+1,0,1)))-1)

Also, the reason the formula didn't work for you is that somehow when you copied it all the " " in the formula because " " (two spaces) - change it back or copy the original one I posted (or the new one) and you should be good :)
 
Last edited:
Upvote 0
Shortened it a bit: =LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-CHOOSE(--ISNUMBER(--RIGHT(A1,5))+1,0,1)))-1)

Also, the reason the formula didn't work for you is that somehow when you copied it all the " " in the formula because " " (two spaces) - change it back or copy the original one I posted (or the new one) and you should be good :)

That code is great and works on all the addresses except for "2527 West Burnett Avenue". Any idea why?

<tbody>
</tbody>
 
Upvote 0
Works for me .. make sure you don't have a trailing space at the end of the cell. Either delete it, or you can change the formula to =LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))-CHOOSE(--ISNUMBER(--RIGHT(A1,5))+1,0,1)))-1)
 
Upvote 0
Works for me .. make sure you don't have a trailing space at the end of the cell. Either delete it, or you can change the formula to =LEFT(A1,FIND("?",SUBSTITUTE(A1," ","?",LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))-CHOOSE(--ISNUMBER(--RIGHT(A1,5))+1,0,1)))-1)

That modified version worked. Thanks!
 
Upvote 0

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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