I have two tables filled with facility names and zip codes (and a bunch of irrelevant other data) each. The tables come from two separate sources and I'd like to link them. The problem is, the facility names are many times written slightly differently (abbreviations, apostrophes, etc.). The Zip code happens to be a good limiter, cutting down several thousand potential matches to only a handful. My problem is,
How can I match the two tables given a zip code match and an approximate name match:
|facility|zip | |facility|zip |
|azyt |10000| No Match|aaaa |10000|
|abba |10000| Match |abb' |10000|
One method I thought of was for each row in table A, comb through table B's zip codes and find all rows that have a matching zip code. Then somehow test which name is MOST similar, likely by comparing the left most characters (?). There is always a match, just not perfect.
Here's my incomplete code:
Dim facilityName, facilityZip, otherName
For i = 1 To Worksheets("Facility").UsedRange.Rows.Count
facilityName = Worksheets("Facility").Cells(i, 2)
facilityZip = Worksheets("Facility").Cells(i, 4)
'Grab all rows in OTHER that have same ZIP
For j = 1 To Worksheets("Other").UsedRange.Rows.Count
otherName = Array()
ub = UBound(otherName) + 1
If Worksheets("Other").Cells(j, 3).Value = facilityZip Then
ReDim Preserve otherName(0 To ub)
otherName(ub) = j
End If
Next j
'Compare names
For Each rw In otherName
'here I would compare each result to the current facilityName. There's likely a better way to do this...
Next rw
Next i
Either help on this code, a suggestion or even a different approach would be very helpful!
Thank you!