By: Afia

In reply to Abby Shuler.

Dear ABBY SHULER
Thank you for your comment. Here, for your first problem, to get rid of the #NAME error, you can copy the following VBA code in a new Excel Workbook. The uploaded Excel file sometimes show problem while running on a different computer, therefore, when you will copy the code to a new workbook, the #NAME error will be solved.

Function AddressCompare(first_string As String, Second_string As String, _
Comparing_Letters As Integer) As Double

Dim int_character As Integer, Comparing_LettersMatch As Integer
Dim n_Gram_List1 As String, n_Gram_List2 As String, n_letter_Gram As Variant
Dim n_Gram_array1 As Variant

For int_character = 1 To Len(first_string) – (Comparing_Letters – 1)
If n_Gram_List1 <> “” Then n_Gram_List1 = n_Gram_List1 & “,”
n_Gram_List1 = n_Gram_List1 & Mid(first_string, int_character, Comparing_Letters)
Next int_character

For int_character = 1 To Len(Second_string) – (Comparing_Letters – 1)
If n_Gram_List2 <> “” Then n_Gram_List2 = n_Gram_List2 & “,”
n_Gram_List2 = n_Gram_List2 & Mid(Second_string, int_character, Comparing_Letters)
Next int_character

n_Gram_array1 = Split(n_Gram_List1, “,”)

For Each n_letter_Gram In n_Gram_array1
If InStr(1, n_Gram_List2, n_letter_Gram) Then
Comparing_LettersMatch = Comparing_LettersMatch + 1
End If
Next n_letter_Gram

AddressCompare = Comparing_LettersMatch / (UBound(n_Gram_array1) + 1)
End Function

After that, save the code and go back to your worksheet. I hope the #NAME error will be gone now.

For your second query, you can use 3 instead of 2. Using 3 will compare 3 letters at a time, and therefore, the result will decrease the match percentage between two addresses.
When you will use 2, it will compare 2 letters at a time, and therefore, the match percentage between two addresses will be higher.
Let me show you that elaborately.
When we use =AddressCompare(C5, F5, 2) in cell E3, the result becomes 1, which indicates the Exact Match.
However, the two addresses are not the same, therefore, using 2 does not give an accurate result.

On the other hand, when we use the formula =AddressCompare(C5, F5, 3) in cell E3, the result becomes 0.970588235, which does not indicate the Exact Match. Rather, it suggests that there is some dissimilarity between the two addresses.
Therefore, using 3 is wise in your case.

Here, another thing must be noted, for your address match, you have to set your own creation while using the IF function.
Let me elaborate on this.
Here, in cell F3, we type the following formula.
IF(AddressCompare(C5, F5, 3)>0.5, "Full Match", "No Match")
Here, in this formula, we give the criteria, that when AddressCompare(C5, F5, 2) is greater than 0.5, the IF function returns “Full Match“. However, when AddressCompare(C5, F5, 2) is not greater than 0.5, the IF function returns “No Match“.
Therefore, in cell F3 the result is “Full Match“.
However, there is some dissimilarity between the two addresses. Hence, the result in cell F3 is not accurate.

To get an accurate result, we will type the following formula in cell F3.

IF(AddressCompare(C5, F5, 3)>0.99, "Full Match", "No Match")
Here, in this formula, we give the criteria, that when AddressCompare(C5, F5, 2) is greater than 0.99, the IF function returns “Full Match“. However, when AddressCompare(C5, F5, 2) is not greater than 0.99, the IF function returns “No Match“.
Therefore, in cell F3 the result is “No Match“.
This is the correct result.

I really hope that you get your answer, and that you can solve your problems.
If you face any problem, you can always let us know.

Regards,
Afia Aziz Kona