Hello,
I am attempting to update a macro that compares two separate sheets of contact info and matches on Last Name. I started working with a macro I found that solved part of my problem and am looking to update it further. Right now, the macro is matching the last name column from sheet 1 to last names in sheet 2 and displaying the matching rows onto sheet 3. I would like to add a comparison to also do a fuzzy match on addresses in addition to matching the last name. I believe this needs to happen within the AutoFilter block below but don’t quite understand how it’s working currently. Any help in explaining it and making the necessary adjustments to add the address match would be very helpful. Thank you!
Sub ExtractCommonDetails()
Dim sws1 As Worksheet, sws2 As Worksheet, dws As Worksheet
Dim slr1 As Long, slr2 As Long
Dim x
Application.ScreenUpdating = False
Set sws1 = Sheets("Sheet1")
Set sws2 = Sheets("Sheet2")
Set dws = Sheets("Sheet3")
slr2 = sws2.Cells(Rows.Count, 1).End(xlUp).Row
dws.Cells.Clear
If slr2 < 2 Then
MsgBox "No records on Sheet2", vbExclamation, "Records Not Found!"
Exit Sub
Else
x = sws2.Range("A2:A" & slr2).Value
End If
With sws1.Range("A1").CurrentRegion
.AutoFilter field:=1, Criteria1:=Application.Transpose(x), Operator:=xlFilterValues
Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy dws.Range("A1")
.AutoFilter
End With
dws.Activate
dws.Columns.AutoFit
dws.Range("A1").CurrentRegion.Borders.Color = vbBlack
Application.ScreenUpdating = True
MsgBox "Task Completed.", vbInformation, "Done!"
End Sub
Bookmarks