View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default duplicate a row with a macro

Hi,

This copes each row in Sheet 1 180 times into sheet 2. Alt +F11 to open Vb
editor. Right click 'This Workbook' and insert module and paste this in. Tap
F5 in VB editor to run it.

Sub copyit()
Dim MyRange As Range
Sheets("Sheet2").Select
lastrow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets("Sheet1").Range("A1:A" & lastrow)
For Each c In MyRange
c.EntireRow.Copy
lastrow2 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
For x = 0 + lastrow2 To 180 + lastrow2
Cells(x, 1).PasteSpecial
Next
Next
End Sub

Mike

"craig51" wrote:

Hello all,

In excel, I want to write a macro that will do the following.

Lets say I have a sheet with 300 rows

I want to copy the first row, and paste this 180times in a separate worksheet.

Once its done this, move to the second row, and repeat the above, with it
being pasted under what i just did above, until its at the end of all the
rows.

Anyone got a scooby on how to do this!

Cheers