I wrote a code to copy and paste a list of persons 12 times each. My code works perfectly when I pass a range that looks like this
Worksheets("DPs").Range("A2:D2").Copy
That will copy the first person on the list all the way down on the correct worksheet.
However when I try pass a range like this it gives me an object-defined error:
Worksheets("DPs").Range(Cells(i + 1, 1), Cells(i + 1, 4)).Copy
Looking online I can supposedly pass a range with the cells method but it won't work.
Any ideas? Here is my complete code:
Sub addDpRep()
Dim x As Integer
Dim y As Integer
x = Worksheets("DPs").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
For i = 1 To x
y = Worksheets("FOR FILE").Range("B:B").Cells.SpecialCells(xlCellTypeConstants).Count
Worksheets("DPs").Range(Cells(i + 1, 1), Cells(i + 1, 4)).Copy
For j = 1 To 12
Worksheets("FOR FILE").Cells(y + j, 2).PasteSpecial Paste:=xlPasteValues
Next j
Next i
End Sub