Find duplicated values and paste range results on next sheet - nextavailable row

J

J.W. Aldridge

Sheet 1. Has two sets of data. B6:G and I6:N.

Numeric values in columns B6 & I6.

For any instance that the number in B6 is also repeated in I6, copy
the row B:G to second sheet.

Second sheet "results" already has data starting at a4:F4.

Each time code is run, place the data on the next available row.

The code below is a good start, it copies any numbers matching in B &
I to second sheet. But it does not paste the range B:G for the number.
And it does not find the next available row.



Sub ABC()
Dim cell As Range, c As Range
Dim i As Range, rw As Long
Dim sh As Worksheet
With Worksheets("Data")
Set c = .Range(.Cells(6, "B"), .Cells(6, "B").End(xlDown))
Set i = .Range(.Cells(6, "I"), .Cells(6, "I").End(xlDown))
End With
rw = 2

Set sh = Worksheets("RESULTS")
For Each cell In c
If Application.CountIf(i, cell) > 0 Then
sh.Cells(rw, 1) = cell
rw = rw + 1
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top