Function street(rng As Range)
'Created by Peezy (Brandon Parrott)
'Used to Split full addresses in a single column into mutiple columns
'To use put =street(a1) into your street column
Dim str As String
If InStr(rng.Value, "DR") > 0 Then 'Drive
str = InStr(rng.Value, "DR") + 2
street = Left(rng, str)
ElseIf InStr(rng.Value, "CIR") > 0 Then 'circle
str = InStr(rng.Value, "CIR") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "ST") > 0 Then 'Street
str = InStr(rng.Value, "ST") + 2
street = Left(rng, str)
ElseIf InStr(rng.Value, "RD") > 0 Then 'Road
str = InStr(rng.Value, "RD") + 2
street = Left(rng, str)
ElseIf InStr(rng.Value, "AVE") > 0 Then 'Avenue
str = InStr(rng.Value, "AVE") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "LN") > 0 Then 'Lane
str = InStr(rng.Value, "LN") + 2
street = Left(rng, str)
ElseIf InStr(rng.Value, "WAY") > 0 Then 'Way
str = InStr(rng.Value, "WAY") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "RDG") > 0 Then 'Ridge
str = InStr(rng.Value, "RDG") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "PKWY") > 0 Then 'Parkway
str = InStr(rng.Value, "PKWY") + 4
street = Left(rng, str)
ElseIf InStr(rng.Value, "HWY") > 0 Then 'Highway
str = InStr(rng.Value, "HWY") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "TERR") > 0 Then 'Terrace
str = InStr(rng.Value, "TERR") + 4
street = Left(rng, str)
ElseIf InStr(rng.Value, "TER") > 0 Then 'Terrace
str = InStr(rng.Value, "TER") + 3
street = Left(rng, str)
ElseIf InStr(rng.Value, "BLVD") > 0 Then 'Boulavard
str = InStr(rng.Value, "BLVD") + 4
street = Left(rng, str)
ElseIf InStr(rng.Value, "LOOP") > 0 Then 'Loop
str = InStr(rng.Value, "Loop") + 4
street = Left(rng.str)
ElseIf InStr(rng.Value, "P O BOX") > 0 Then 'P.O. Box Address
street = pobox(rng)
ElseIf InStr(rng.Value, "PO BOX") > 0 Then 'PO Box address Incase there is no space between P and O
street = pobox(rng)
Else
street = "Error"
End If
End Function
Function pobox(rng As Range)
'Created by Peezy (Brandon Parrott)
'Used to Split full addresses in a single column into mutiple columns
'pobox function is used along with the street function, no need to mess with this in the sheet
'Determines if the address is a P.O. Box
Dim strr As String, result As String
Dim r As Integer, t As Integer
strr = rng
If InStr(1, strr, "1") = 9 Then
r = InStr(1, strr, "1")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "2") = 9 Then
r = InStr(1, strr, "2")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "3") = 9 Then
r = InStr(1, strr, "3")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "4") = 9 Then
r = InStr(1, strr, "4")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "5") = 9 Then
r = InStr(1, strr, "5")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "6") = 9 Then
r = InStr(1, strr, "6")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "7") = 9 Then
r = InStr(1, strr, "7")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "8") = 9 Then
r = InStr(1, strr, "8")
t = InStr(r, strr, " ")
result = Left(strr, t)
ElseIf InStr(1, strr, "9") = 9 Then
r = InStr(1, strr, "9")
t = InStr(r, strr, " ")
result = Left(strr, t)
Else
result = "Error"
End If
pobox = result
End Function
=city(a2) Function:
Function city(rng As Range)
'Created by Peezy (Brandon Parrott)
'Used to Address City from full address
'To use place =city(a1) into city column
Dim x As String
Dim str As String
Dim p As String, o As String, l As String
If InStr(rng.Value, "DR") > 0 Then 'Drive
str = InStr(rng.Value, "DR") + 2
ElseIf InStr(rng.Value, "CIR") > 0 Then 'Circle
str = InStr(rng.Value, "CIR") + 3
ElseIf InStr(rng.Value, "ST") > 0 Then 'Street
str = InStr(rng.Value, "ST") + 2
ElseIf InStr(rng.Value, "RD") > 0 Then 'Road
str = InStr(rng.Value, "RD") + 2
ElseIf InStr(rng.Value, "AVE") > 0 Then 'Avenue
str = InStr(rng.Value, "AVE") + 3
ElseIf InStr(rng.Value, "LN") > 0 Then 'Lane
str = InStr(rng.Value, "LN") + 2
ElseIf InStr(rng.Value, "WAY") > 0 Then 'Way
str = InStr(rng.Value, "WAY") + 3
ElseIf InStr(rng.Value, "RDG") > 0 Then 'Ridge
str = InStr(rng.Value, "RDG") + 3
ElseIf InStr(rng.Value, "PKWY") > 0 Then 'Parkway
str = InStr(rng.Value, "PKWY") + 4
ElseIf InStr(rng.Value, "HWY") > 0 Then 'Highway
str = InStr(rng.Value, "HWY") + 3
ElseIf InStr(rng.Value, "TERR") > 0 Then 'Terrace
str = InStr(rng.Value, "TERR") + 4
ElseIf InStr(rng.Value, "TER") > 0 Then 'Terrace
str = InStr(rng.Value, "TER") + 3
ElseIf InStr(rng.Value, "BLVD") > 0 Then 'boulevard
str = InStr(rng.Value, "BLVD") + 4
ElseIf InStr(rng.Value, "P O BOX") > 0 Then 'If address is a P O Box
p = InStr(rng.Value, "BOX") + 4
str = InStr(p, rng.Value, " ")
ElseIf InStr(rng.Value, "PO BOX") > 0 Then 'If address is a PO Box
p = InStr(rng.Value, "BOX") + 4
str = InStr(p, rng.Value, " ")
Else
x = "Error"
End If
x = Left(rng, str)
Dim r As String
Dim s As String
Dim v As String
Dim reg As String
Dim obj As String
Dim result As String
Dim a As String
s = Right(rng, 10)
If IsNumeric(s) = True Then
v = 12
ElseIf IsNumeric(s) = False Then
v = 8
End If
r = Len(rng.Value) - v
reg = Left(rng, r)
obj = Len(x)
a = r - obj
result = Right(reg, a)
city = result
End Function
=state(a2) Function:
Bookmarks