ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find duplicated values and paste range results on next sheet - nextavailable row (https://www.excelbanter.com/excel-programming/425263-find-duplicated-values-paste-range-results-next-sheet-nextavailable-row.html)

J.W. Aldridge

Find duplicated values and paste range results on next sheet - nextavailable row
 
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


All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com