Copy and paste list members multiple times

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
537
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a series of ID's residing on one sheet that I need to copy over to a second sheet. There are currently 37 ID's starting in C14 of Sheet1 through C50 but the number will vary. I need to paste each ID into Sheet2 starting in cell D7. Each ID needs to get pasted 6x, then I need to skip a row, then paste the next ID 6x and so forth until complete. Below is a sample of the end result I want to achieve through VBA.

D7ID01
D8ID01
D9ID01
D10ID01
D11ID01
D12ID01
D13
D14ID02
D15ID02
D16ID02
D17ID02
D18ID02
D19ID02
D20
D21ID03
D22ID03
......

<tbody>
</tbody>
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this:
Code:
Sub Copy_Count()
'Modified 7/31/2019 11:52:55 PM  EDT
Application.ScreenUpdating = False
Dim i As Long
Dim ans As Long
ans = 7
Dim Lastrow As Long
Lastrow = Sheets(1).Cells(Rows.Count, "C").End(xlUp).Row
For i = 14 To Lastrow
    Sheets(1).Cells(i, "C").Copy Sheets(2).Cells(ans, "D").Resize(6)
    ans = ans + 6
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks so much. I had to make a slight change to account for the blank row but does exactly what I needed.

Code:
[COLOR=#333333]ans = ans + 6

[/COLOR]to

[COLOR=#333333]ans = ans + 7[/COLOR]
 
Upvote 0
Yes. I forgot about the blank row you wanted. Glad to see you know how to mody script to your needs.
Thanks so much. I had to make a slight change to account for the blank row but does exactly what I needed.

Code:
[COLOR=#333333]ans = ans + 6

[/COLOR]to

[COLOR=#333333]ans = ans + 7[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

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