ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Variable Number of Rows (https://www.excelbanter.com/excel-programming/338592-inserting-variable-number-rows.html)

bundyloco[_7_]

Inserting Variable Number of Rows
 

I'm trying to create a chunk of code that copies an entire row and then
inserts a variable amount. here is the code

insertrows = 3 + prodlength
Rows("3:3").Select
Selection.Copy
Rows("4:insertows").Select
Selection.Insert Shift:=xlDown

Is it possible to do something like this? I'm trying to do this method
because it copying and inserting rows preserves all the formatting. The
variable prodlenght is the number of products found off another
worksheet in the workbook.


--
bundyloco
------------------------------------------------------------------------
bundyloco's Profile: http://www.excelforum.com/member.php...o&userid=23386
View this thread: http://www.excelforum.com/showthread...hreadid=399996


PY & Associates[_4_]

Inserting Variable Number of Rows
 
Would you consider replacing
Rows("4:insertows").Select
Selection.Insert Shift:=xlDown


with
Rows("4:insertows").entirerow.insert

"bundyloco" wrote:


I'm trying to create a chunk of code that copies an entire row and then
inserts a variable amount. here is the code

insertrows = 3 + prodlength
Rows("3:3").Select
Selection.Copy
Rows("4:insertows").Select
Selection.Insert Shift:=xlDown

Is it possible to do something like this? I'm trying to do this method
because it copying and inserting rows preserves all the formatting. The
variable prodlenght is the number of products found off another
worksheet in the workbook.


--
bundyloco
------------------------------------------------------------------------
bundyloco's Profile: http://www.excelforum.com/member.php...o&userid=23386
View this thread: http://www.excelforum.com/showthread...hreadid=399996



Bob Phillips[_6_]

Inserting Variable Number of Rows
 
insertrows = 3 + prodlength
Rows("3:3").Copy
Rows("4:" & insertrows).Insert

--

HTH

RP
(remove nothere from the email address if mailing direct)


"bundyloco" wrote
in message ...

I'm trying to create a chunk of code that copies an entire row and then
inserts a variable amount. here is the code

insertrows = 3 + prodlength
Rows("3:3").Select
Selection.Copy
Rows("4:insertows").Select
Selection.Insert Shift:=xlDown

Is it possible to do something like this? I'm trying to do this method
because it copying and inserting rows preserves all the formatting. The
variable prodlenght is the number of products found off another
worksheet in the workbook.


--
bundyloco
------------------------------------------------------------------------
bundyloco's Profile:

http://www.excelforum.com/member.php...o&userid=23386
View this thread: http://www.excelforum.com/showthread...hreadid=399996





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

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