View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 168
Default Quick and Easy: Copying and Inserting Lines Using VBA

This code is sloppy and I'm sure there is some overkill in it, but it works.
The key is, before you run the code, you must click on the cell in column A
at which row you would like to start this process. If you want to start at
the top, just click on A1 to select the cell, and then run this code. This
will find the last row which has data in column A to determine how many
times the duplication process must repeat. If the last row to be duplicated
does not have data in column A of that row, you'll need to modify the code
slightly. Save you're work first.
HTH,
Paul


Sub Macro1()
i = Range("A65536").End(xlUp).Row
s = i - ActiveCell.Row + 1
c = 1

For r = 1 To i
ActiveCell.EntireRow.Select
Selection.Copy
Rows(Selection.Row & ":" & Selection.Row).Offset(1, 0).Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(1, 0).Select
If c = s Then End
c = c + 1
Next r
End Sub



"Kristen" wrote in
message ...

I have an easy one for you guys.... I want to use VBA to make a simple
loop that will go down the page in Excel in my current file and
duplicate each row, adding it into the row below it. Got any simple
VBA code?? I'm too tired to come up with it on my own! THank you!

Kristen


--
Kristen
------------------------------------------------------------------------
Kristen's Profile:
http://www.excelforum.com/member.php...o&userid=33199
View this thread: http://www.excelforum.com/showthread...hreadid=570526