Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub copy180()
Set oldsht = ActiveSheet Worksheets.Add after:=Sheets(Sheets.Count) ActiveSheet.Name = "Copy 180" Set newsht = ActiveSheet NumberofCopies = 180 OldRowCount = 1 NewRowCount = 1 With oldsht Do While .Range("A" & OldRowCount) < "" .Rows(OldRowCount).Copy _ Destination:=newsht.Rows(NewRowCount & ":" & _ (NewRowCount + NumberofCopies - 1)) NewRowCount = NewRowCount + NumberofCopies OldRowCount = OldRowCount + 1 Loop End With End Sub "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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanking you both, much much appriecated!!!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Duplicate remover (no macro) | Excel Discussion (Misc queries) | |||
macro for duplicate values | Excel Worksheet Functions | |||
Macro - Cut and paste a row if duplicate | Excel Programming | |||
Macro to delete duplicate data | Excel Programming | |||
Macro that controlls duplicate values | Excel Programming |