Text to Columns/Formula to Separate Address Data

m_geragh

New Member
Joined
Jan 14, 2014
Messages
11
I have tried many different ways to separate the house number from the street name:
=(right) function with 'find' number
text to columns
replacing 'street' with 'address,' etc so I could separate by the ',' but there is so many variables.

Does anybody have an easy way to separate the house number from the street name in the below fictinary sample:

[TABLE="width: 195"]
<colgroup><col></colgroup><tbody>[TR]
[TD]HIGH ROAD NORTH 51
[/TD]
[/TR]
[TR]
[TD]HIGH ROAD NORTH 51
[/TD]
[/TR]
[TR]
[TD]WESTFIED ROAD 26
[/TD]
[/TR]
[TR]
[TD]TYNE CLOSE 12
[/TD]
[/TR]
[TR]
[TD]TYNE CLOSE 18
[/TD]
[/TR]
[TR]
[TD]TYNE CLOSE 31
[/TD]
[/TR]
[TR]
[TD]TYNE CLOSE 32
[/TD]
[/TR]
[TR]
[TD]BANFORD CLOSE 1
[/TD]
[/TR]
[TR]
[TD]BANFORD CLOSE 24
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 3
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 9
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 15
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 17
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 24
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 33
[/TD]
[/TR]
[TR]
[TD]WILLIS AVENUE 34
[/TD]
[/TR]
</tbody>[/TABLE]
...

Many Thanks in advance
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
i used google to find the following assuming your data is in column A and starts in A2

=IF(ISERR(FIND(" ",A2)),"",RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))))
 
Upvote 0
Or, since in your examples the Number always forms the final part of the string, in B2:

=--TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",187)),187))

And in C2:

=TRIM(SUBSTITUTE(A2,B2,""))

Regards
 
Upvote 0
Or, since in your examples the Number always forms the final part of the string, in B2:

=--TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",187)),187))

And in C2:

=TRIM(SUBSTITUTE(A2,B2,""))

Regards

Absolutely spot on - thank you!
 
Upvote 0
Heres another.. more typing than the formula and slower.. but in any case..

Code:
Private Sub CommandButton1_Click()
   Dim objRegex, n
    Set objRegex = CreateObject("vbscript.regexp")
    With objRegex
        .Global = True
        .Pattern = "\d*\d$"
        For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
            Set myMatches = .Execute(Cells(i, 1))
            For Each n In myMatches
                    Cells(i, 2).Value = n
            Next n
        Next i
    End With
End Sub
 
Upvote 0
If you are going to use vba you might as well use the split function on the string and return the Nth element
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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