Hello All,
I have got a bit of code that looks into Column A on Sheet3, finds a match, then Offset copies a value from Sheet8 to the matched row in Sheet3.
This works really well for the first time it finds a match, but what I can't figure out is how to get it to continue to move down the column to look for the next matched cell (as will be immediately obvious to you guru's)
I have a loop in the following code which obviously doesn't work, and that's the part I'm stuck on. Here's what I have so far...
I just can't think where to put the logic to get it to continue to look down the column, find the next match and paste (BTW, the same data will be pasted each time it finds a match).
Any assistance would be greatly appreciated.
Cheers, Toby
I have got a bit of code that looks into Column A on Sheet3, finds a match, then Offset copies a value from Sheet8 to the matched row in Sheet3.
This works really well for the first time it finds a match, but what I can't figure out is how to get it to continue to move down the column to look for the next matched cell (as will be immediately obvious to you guru's)
I have a loop in the following code which obviously doesn't work, and that's the part I'm stuck on. Here's what I have so far...
VBA Code:
Sub Paste_Inci()
Dim i As Integer
Dim finalrow As Integer
FindItem = Sheet8.Range("D1").Value 'The sheet that contains the the match value
On Error Resume Next
FoundItem = Sheet3.Range("A2:A65535").Find(What:=FindItem).Address 'This is the sheet where the data will be pasted
On Error GoTo 0
finalrow = Cells(Rows.Count, 2).End(xlUp).Row
For i = 1 To finalrow
If FoundItem <> "" Then
PasteLocation = Sheet3.Range(FoundItem).Offset(0, 16).Address 'The column where the data will be pasted
Sheet8.Range("G1").Copy Sheet3.Range(PasteLocation)
Else
MsgBox ("Item not found. No action performed.")
End If
i = i + 1
Next i
End Sub
I just can't think where to put the logic to get it to continue to look down the column, find the next match and paste (BTW, the same data will be pasted each time it finds a match).
Any assistance would be greatly appreciated.
Cheers, Toby