Hi, thanks to one of my colleague he has helped me write a formula that will from Sheet "Find" trawl through the list and find a matching name on the Sheet "Internal" and then paste the matching name along with the data along the next five columns in the Sheet "Sheet4".
This all works fine, but i have ran into an issue where if I have 2 lines of data for 1 matching name in the internal sheet. I was hoping to get some help to amend the code that i have to be able to add more than 1 line. I have attached a sample workbook, so hopefully somebody can help.
The following is the code that was written:
Sub CopyRows()
Dim i As Long, k As Long, n As Variant, r As Range
Application.ScreenUpdating = False
With Sheets("INTERNAL")
Set r = Range(.Cells(4, 1), .Cells(4, 1).End(xlDown))
End With
k = 3
i = 2
While Not IsEmpty(Sheets("Find").Cells(i, 1))
n = Application.Match(Sheets("Find").Cells(i, 1).Value, r, 0)
If IsNumeric(n) Then
Sheets("Find").Cells(i, 1).Interior.ColorIndex = 35
k = k + 1
r.Rows(n).Resize(, 5).Copy Sheets("Sheet4").Rows(k)
Else
Sheets("Find").Cells(i, 1).Interior.ColorIndex = 3
End If
i = i + 1
Wend
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Thanks in advance.
Bookmarks