Public Sub CopyIfDupes()
'CONFIG SHEET INFO HERE
Set SrcSh1 = Sheets("Sheet1")
Set SrcSh2 = Sheets("Sheet2")
Set TargSh = Sheets("Sheet3")
Const PolicyNumCol As Integer = 1
For Each PolicyNum In SrcSh1.Cells(1, PolicyNumCol).EntireColumn.SpecialCells(xlCellTypeConstants, 3)
With SrcSh2.Cells(1, PolicyNumCol).EntireColumn
Set c = .Find(PolicyNum.Value, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
With TargSh
NextTargRow = .Cells(.Cells(1, PolicyNumCol).EntireColumn.Cells.Count, PolicyNumCol).End(xlUp).Row + 1
.Cells(NextTargRow, 1).Value = PolicyNum.Value
.Cells(NextTargRow, 2).Value = SrcSh1.Cells(PolicyNum.Row, 2).Value
.Cells(NextTargRow, 3).Value = SrcSh2.Cells(c.Row, 3).Value
.Cells(NextTargRow, 4).Value = SrcSh2.Cells(c.Row, 4).Value
End With
End If
End With
Next PolicyNum
End Sub
Bookmarks