Hi,
Im trying to create a loop though column B, that will copy and paste rows D-G into a new worksheet. Im very new to VBA and am just testing some out some code, this is what i have so far:
Sub looptest()
Dim i As Long
Dim a As Long
Dim da As Worksheet: Set da = Worksheets("Data")
Dim ap As Worksheet: Set ap = Worksheets("Apples")
Dim og As Worksheet: Set og = Worksheets("Oranges")
a = 4
a = a + 1
For i = 2 To Rows.Count
If da.Cells(i, 2) = "Apples" Then
ap.Range("i,4:i,7").Copy
og.Range("a,2:a,5").Paste
End If
Next i
End Sub
I am getting the error Run Time error '1004': Application defined object defined error. Any help on this would be much appreciated.
thanks
Bookmarks