Copy from one cell to another using VBA

lar48ry

Board Regular
Joined
Feb 4, 2005
Messages
53
How do I copy and paste the following (using VBA):

Cell A1 to Cell C2
Cell A2 to Cell C7
Cell A3 to Cell C12

until all cells in column A are copied into every 5th cell in Column C after Cell A1 is copied to Cell C2?

Thank you,
Larry
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try

Code:
Sub test()
Dim LR As Long, i As Long, j As Long
j = 2
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    Range("C" & j).Value = Range("A" & i).Value
    j = j + 5
Next i
End Sub
 
Upvote 0
Perhaps something like this:
Code:
Sub MyLoop()
 
    Application.ScreenUpdating = False
    
    Dim i As Long
    For i = 1 To Range("A1").End(xlDown).Row
        Cells(i * 5 - 3, "C") = Cells(i, "A")
    Next i
    
    Application.ScreenUpdating = True
        
End Sub
 
Upvote 0
Thanks VoG,

It worked like a charm.

Thanks Joe4,

I didn't try this one because the first one worked so well. I'll give it a try when I need to try this across multiple workbooks.

I appreciate the rapid response to this situation. I kept racking my brain but couldn't figure out the the step through requirements.

Larry
 
Upvote 0

Forum statistics

Threads
1,215,302
Messages
6,124,148
Members
449,146
Latest member
el_gazar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top