I am using two workbooks to search for missing information that is in one book but not in the other. My code works but in some instances I have multiple matches being returned and only one value is entered in to the cell. I need to be able to add the first match to the existing row in workbook1 and then create a new row for each additional match and copy over columns "B", "C" and "D" from workbook2 on to workbook1, underneath the original row in workbook1, leaving column "A" empty for each new row
This is the code that I am using
PGNewbie()
Dim w1 As Worksheet, w2 As Worksheet
Dim wbnew As Workbook
Dim c As Range, FR As Variant
Dim d As Range
Dim e As Range
Application.ScreenUpdating = False
Set w2 = Workbooks("Book2.xlsx").ActiveSheet
Set w1 = Workbooks("Book1.xlsx").ActiveSheet
For Each c In w1.Range("C2", w1.Range("C" & Rows.Count).End(xlUp))
FR = Application.Match(c, w2.Columns("C"), 0)
If IsNumeric(FR) Then
c.Offset(, 1).Value = w2.Range("D" & FR).Value
End If
Next c
End Sub
This is the code that I am using
PGNewbie()
Dim w1 As Worksheet, w2 As Worksheet
Dim wbnew As Workbook
Dim c As Range, FR As Variant
Dim d As Range
Dim e As Range
Application.ScreenUpdating = False
Set w2 = Workbooks("Book2.xlsx").ActiveSheet
Set w1 = Workbooks("Book1.xlsx").ActiveSheet
For Each c In w1.Range("C2", w1.Range("C" & Rows.Count).End(xlUp))
FR = Application.Match(c, w2.Columns("C"), 0)
If IsNumeric(FR) Then
c.Offset(, 1).Value = w2.Range("D" & FR).Value
End If
Next c
End Sub