I need a function to find if 2 addresses are similar. You may think that this is a simple compare, however you can have a bunch of different formatted addresses that are the same thing:
ie 123 Fake Street = 123 Fake St. = 123 Fake St = 123 Fake Street Apt 123
Now I have a decent function in place, but I need to fix some lingering errors and I dont know the best way of doing it.
(I'm doing this in vba, but I just need pseudocode)
Function addresscheck(ByVal first As String, ByVal last As String) As String
Dim name1 As Variant
Dim name2 As Variant
Dim num, textAs Boolean
num = False
text = False
name1 = Split(first, " ")
name2 = Split(last, " ")
For i = 0 To UBound(name1)
For j = 0 To UBound(name2)
'if both are numbers and equal, the street number is correct
If IsNumeric(name1(i)) Then
If IsNumeric(name2(j)) Then
If name1(i) = name2(j) Then
num = True
End If
End If
'if both are strings and equal, the street name is correct
ElseIf Len(name1(i)) > 3 Then
If UCase(name1(i)) = UCase(name2(j)) Then
text = True
End If
End If
Next j
Next i
If UCase(first) = UCase(last) Then
addresscheck = "Match"
ElseIf Not num And Not text Then
addresscheck = "No Match"
ElseIf Not num And text Then
addresscheck = "Text Only"
ElseIf num And Not text Then
addresscheck = "Number Only"
ElseIf num And text Then
addresscheck = "Match"
End If
End Function
Problem is this will give me a match if I have something like this: 2 Queen Street & 2 King Street because Street is equal (I tried to get rid of this by only allowing words with a length greater than 3 to be compared, but same problems arise I guess)
And it will give a match if I have 2 King Street & 2 King Cresent.
I can't do comparisons by placement because then something like Apt. 100 2 King Street = 2 King Street = 2 King Street Apt. 100 will return as no match.
Question
thevink
Need a little help:
I need a function to find if 2 addresses are similar. You may think that this is a simple compare, however you can have a bunch of different formatted addresses that are the same thing:
ie 123 Fake Street = 123 Fake St. = 123 Fake St = 123 Fake Street Apt 123
Now I have a decent function in place, but I need to fix some lingering errors and I dont know the best way of doing it.
(I'm doing this in vba, but I just need pseudocode)
Problem is this will give me a match if I have something like this: 2 Queen Street & 2 King Street because Street is equal (I tried to get rid of this by only allowing words with a length greater than 3 to be compared, but same problems arise I guess)
And it will give a match if I have 2 King Street & 2 King Cresent.
I can't do comparisons by placement because then something like Apt. 100 2 King Street = 2 King Street = 2 King Street Apt. 100 will return as no match.
Any help is appreciated.
Link to comment
Share on other sites
7 answers to this question
Recommended Posts