I have an excel sheet, with a column filled with about 10 complete standard addresses with intermittent blank (nulls)
All addresses are in the same format:
123 Street Name, Suburb QLD 4123
What i'm trying to do is create an automatic splitter where upon a BUtton7_Click the macro loops through the column and splits up the street name with number, suburb, state code and post code into separate columns. Thanks to a contributor here I got a good core function working which separates the address given as a static value.
Sub Button7_Click()
Dim strTest As String
Dim arr1
Dim arr2
Dim StreetAddress As String
Dim Postcode As String
Dim StateCode As String
Dim SubUrb As String
strTest = "62 Norma Rd, Myaree WA 6154"
arr1 = Split(strTest, ",")
arr2 = Split(Trim(arr1(1)), Space(1))
StreetAddress = arr1(0)
Postcode = arr2(2)
StateCode = arr2(1)
SubUrb = arr2(0)
Range("E3").Value = arr1(0)
Range("F3").Value = arr2(0)
Range("G3").Value = arr2(1)
Range("H3").Value = arr2(2)
End Sub
The issue I'm facing is getting that to run...
- In a loop
- Independent of the column size (However I do know I need to use something like "For LngRow = 2 To Wksht.Range("D" & Wksht.Rows.Count).End(xlUp).Row"
- Ignoring Null values (Need to use if Len(address_string) > 0 Then exit)
- Using ubound for double name suburbs.
I figure the best first step is to build the loop, then implement case validation, then column count and lastly ubound.
However I tried using a loop function used in my last question but it didn't work and I have never used ubound before, can someone help me?