ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quick and Easy: Copying and Inserting Lines Using VBA (https://www.excelbanter.com/excel-programming/370041-quick-easy-copying-inserting-lines-using-vba.html)

Kristen[_8_]

Quick and Easy: Copying and Inserting Lines Using VBA
 

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


PCLIVE

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




Kristen[_9_]

Quick and Easy: Copying and Inserting Lines Using VBA
 

Thank You!!!!

:

--
Kriste
-----------------------------------------------------------------------
Kristen's Profile: http://www.excelforum.com/member.php...fo&userid=3319
View this thread: http://www.excelforum.com/showthread.php?threadid=57052



All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com