Copy and paste list members multiple times

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
539
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.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]D7[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D8[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D9[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D10[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D11[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D12[/TD]
[TD]ID01[/TD]
[/TR]
[TR]
[TD]D13[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]D14[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D15[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D16[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D17[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D18[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D19[/TD]
[TD]ID02[/TD]
[/TR]
[TR]
[TD]D20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]D21[/TD]
[TD]ID03[/TD]
[/TR]
[TR]
[TD]D22[/TD]
[TD]ID03[/TD]
[/TR]
[TR]
[TD]...[/TD]
[TD]...[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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