Separating City Name From Addresses

blackystrat

New Member
Joined
Aug 5, 2014
Messages
26
Hi

Excel 2013

I have a list of 4422 addresses where the city name is suffixed at the end of the address.

The problem is that there is no delimiter in front of the city names and the number of words in the City Name varies between 1-3

How could I split them up so that the city is in a new column.

Please find a sample list attached which shows how I have it and how I want it - https://expirebox.com/download/87a60cc161ae45e497edb34c4410198a.html

Kindly advise

Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
blackystrat,

Every address in your sample list contains a number before the city name. Assuming this is true for all the addresses, you might consider the following...

Code:
Sub SplitCity_1026429()
Application.ScreenUpdating = False
Dim lenth As Long, i As Long
Dim r As Range
For Each r In Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    lenth = Len(r.Value)
    For i = lenth To 1 Step -1
        If Mid(r.Value, i, 1) Like "[0-9]" Then
            r.Offset(0, 1).Value = Trim(Left(r.Value, i))
            r.Offset(0, 2).Value = Trim(Right(r.Value, lenth - i))
            Exit For
        End If
    Next i
Next r
ActiveSheet.Columns.AutoFit
Application.ScreenUpdating = True
End Sub

Cheers,

tonyyy
 
Last edited:
Upvote 0
And since you have 4400 addresses, an array approach might be a bit quicker...

Code:
Sub SplitCity_1026429r2()
Application.ScreenUpdating = False
Dim lenth As Long, i As Long, n As Long
Dim arr As Variant
arr = Range("A2:C" & Cells(Rows.Count, "A").End(xlUp).Row)
For n = 1 To UBound(arr, 1)
    lenth = Len(arr(n, 1))
    For i = lenth To 1 Step -1
        If Mid(arr(n, 1), i, 1) Like "[0-9]" Then
            arr(n, 2) = Trim(Left(arr(n, 1), i))
            arr(n, 3) = Trim(Right(arr(n, 1), lenth - i))
            Exit For
        End If
    Next i
Next n
Range("A2:C" & Cells(Rows.Count, "A").End(xlUp).Row) = arr
ActiveSheet.Columns.AutoFit
Application.ScreenUpdating = True
End Sub
 
Upvote 0
If you were looking for a formula approach..


Book1
ABC
3One E. Washington Street Ste. 1900 PhoenixOne E. Washington Street Ste. 1900Phoenix
42525 E. Arizona Biltmore Circle Ste. B-218 Phoenix2525 E. Arizona Biltmore Circle Ste. B-218Phoenix
52575 E. Camelback Road Ste. 1100 Phoenix2575 E. Camelback Road Ste. 1100Phoenix
6101 Montgomery Street Ste. 2300 San Francisco101 Montgomery Street Ste. 2300San Francisco
7One Market Spear Tower Ste. 2200 San FranciscoOne Market Spear Tower Ste. 2200San Francisco
8921 S. 8th Avenue Stop 8410 Pocatello921 S. 8th Avenue Stop 8410Pocatello
9TCA - Cheri Mattson PO Box 126 Twin FallsTCA - Cheri Mattson PO Box 126Twin Falls
10151 4th Street West Unit 3359 Ketchum151 4th Street West Unit 3359Ketchum
112300 N. Yellowstone Hwy. Ste. 210 Idaho Falls2300 N. Yellowstone Hwy. Ste. 210Idaho Falls
122235 E. 25th Street Ste. 250 Idaho Falls2235 E. 25th Street Ste. 250Idaho Falls
133456 E. 17th Street Ste. 280 Idaho Falls3456 E. 17th Street Ste. 280Idaho Falls
14339 W. State Street Ste. 205 Eagle339 W. State Street Ste. 205Eagle
15291 E. Shore Drive Ste. 200 Eagle291 E. Shore Drive Ste. 200Eagle
16291 E. Shore Drive Ste. 200 Eagle291 E. Shore Drive Ste. 200Eagle
172825 S. Meridian Road Ste. 150 Meridian2825 S. Meridian Road Ste. 150Meridian
18524 Third Street South PM Box 142 Nampa524 Third Street South PM Box 142Nampa
195700 E. Franklin Road Ste. 200 Nampa5700 E. Franklin Road Ste. 200Nampa
20608 Northwest Blvd. Ste. 300 Coeur d'Alene608 Northwest Blvd. Ste. 300Coeur d'Alene
Sheet2
Cell Formulas
RangeFormula
B3=LEFT(A3,LOOKUP(1,-MID(A3,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A3))),1),ROW(INDEX(A:A,1):INDEX(A:A,LEN(A3)))))
C3=TRIM(SUBSTITUTE(A3,B3,""))
 
Last edited:
Upvote 0
Wow... I got mentioned in the same sentence as Peter! ;-)

You're very welcome, blackystrat. Glad it worked out...
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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