Macro code to copy a cell and paste it to the next 2 cells
Try
Sub copycell()
For i = 1 To 1000 Step 4
Cells(1, i).Copy
Range(Cells(1, i + 1), Cells(1, i + 3)).PasteSpecial
Next i
End Sub
or simply
Sub copycell()
For i = 1 To 100 Step 4
Range(Cells(1, i + 1), Cells(1, i + 3)).Value = Cells(1, i).Value
Next i
End Sub
Step
keyword is used to specify a different increment for the counter variable of a loop. Step
changes the value used to increment the counter. In this case, i
will increment by 4 i.e. from 1 to 5
then to 9
then to 13
and so on...
Above code will copy cells in a row across to the right.
If you want to copy cells down in a column then you can use following code.
Sub copycell()
For i = 1 To 100 Step 4
Range(Cells(i + 1, 1), Cells(i + 3, 1)) = Cells(i, 1)
Next i
End Sub
Here it is, 4 steps between each loop in order to move to the fifth cell from the first cell.
Sub copycell()
for i= 1 to 1000 step 4
Cells(1,i+1) = Cells(1, i)
Cells(1,i+2) = Cells(1, i)
Cells(1,i+3) = Cells(1, i)
next i
End sub