Macro to copy and paste

Mxer911

New Member
Joined
Jan 14, 2010
Messages
17
So here is my problem.

I need to create a macro that will copy and paste row 1, "x" number of times on sheet 2, and after it has done that move to row 2 and copy and paste it "x" number or times on sheet 2.

"x" will be a value stored in lets say column D

Here is an example of how the data will start:

Before.jpg


Here is an example of how the data will finish:

After.jpg



This may be a simple task but I just can't seem to wrap my head around it this morning. As usual any and all help is greatly appreciated.

Thanks in advanced
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
This should help
Might be messy - as Im still learning :)

Code:
Sub neww()
Application.ScreenUpdating = False
i = 2 'as your QTy starts from D2
x = Sheets("Sheet1").Range("D" & i)
n = 1
Sheets("Sheet1").Activate
Do While x <> ""
Range("A" & i & ":D" & i).Copy
Do Until n > x
Lngrow = Sheets("Sheet2").Range("A65536").End(xlUp).Row + 1
Sheets("Sheet2").Activate
Range("A" & Lngrow).PasteSpecial
n = n + 1
Loop
n = 1
i = i + 1
x = Sheets("Sheet1").Range("D" & i)
Sheets("Sheet1").Activate
Loop
Application.CutCopyMode = False
Application.ScreenUpdating = True
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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