Hi guys,
Im just starting with VBA.
could you help me and tell how I can do this operation with a loop. Now Im changing the offset values manually but I know there is a loop possible.
Could you please tell me how to do it with explanation.
Sub iex()
Dim i As Integer
Dim y As Integer
y = 1
i = 107
Range(Cells(17, 5), Cells(113, 5)).Copy Destination:=Cells(17, 45)
Range(Cells(17 + i, 5), Cells(113 + i, 5)).Copy Destination:=Cells(17, 45 + y)
Range(Cells(17 + 2 * i, 5), Cells(113 + 2 * i, 5)).Copy Destination:=Cells(17, 45 + 2 * y)
Range(Cells(17 + 3 * i, 5), Cells(113 + 3 * i, 5)).Copy Destination:=Cells(17, 45 + 3 * y)
Range(Cells(17 + 4 * i, 5), Cells(113 + 4 * i, 5)).Copy Destination:=Cells(17, 45 + 4 * y)
Range(Cells(17 + 5 * i, 5), Cells(113 + 3 * i, 5)).Copy Destination:=Cells(17, 45 + 3 * y)
.
.
.
End Sub
Im just starting with VBA.
could you help me and tell how I can do this operation with a loop. Now Im changing the offset values manually but I know there is a loop possible.
Could you please tell me how to do it with explanation.
Sub iex()
Dim i As Integer
Dim y As Integer
y = 1
i = 107
Range(Cells(17, 5), Cells(113, 5)).Copy Destination:=Cells(17, 45)
Range(Cells(17 + i, 5), Cells(113 + i, 5)).Copy Destination:=Cells(17, 45 + y)
Range(Cells(17 + 2 * i, 5), Cells(113 + 2 * i, 5)).Copy Destination:=Cells(17, 45 + 2 * y)
Range(Cells(17 + 3 * i, 5), Cells(113 + 3 * i, 5)).Copy Destination:=Cells(17, 45 + 3 * y)
Range(Cells(17 + 4 * i, 5), Cells(113 + 4 * i, 5)).Copy Destination:=Cells(17, 45 + 4 * y)
Range(Cells(17 + 5 * i, 5), Cells(113 + 3 * i, 5)).Copy Destination:=Cells(17, 45 + 3 * y)
.
.
.
End Sub