ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Row insertion macro (https://www.excelbanter.com/excel-programming/282448-row-insertion-macro.html)

jeff

Row insertion macro
 
Let's say I have a spreadsheet in which a unique number
is entered into column A, rows 1 through 5.

Column A
Row 1 100
Row 2 200
Row 3 300
Row 4 400
Row 5 500

I need a macro that will insert 9 rows after each entry,
copying original value. To further clarify, the macro
needs to read the value of cell 1A (100), and then insert
9 rows underneath containing the same value (100). I need
this done for all 5 original rows. Thanks.

Tom Ogilvy

Row insertion macro
 
Sub AATester1()
Dim i As Long
For i = 5 To 1 Step -1
Rows(i + 1).Resize(9).Insert
Cells(i, 1).Resize(10).Value = Cells(i, 1)
Next

End Sub


--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Let's say I have a spreadsheet in which a unique number
is entered into column A, rows 1 through 5.

Column A
Row 1 100
Row 2 200
Row 3 300
Row 4 400
Row 5 500

I need a macro that will insert 9 rows after each entry,
copying original value. To further clarify, the macro
needs to read the value of cell 1A (100), and then insert
9 rows underneath containing the same value (100). I need
this done for all 5 original rows. Thanks.




david mcritchie

Row insertion macro
 
Hi anonymous poster Jeff,
Only 5 rows or all of your rows. In any case you insert or delete
rows from the bottom up. If you want only 5 rows then you can
hard code the 5 in the macro. Since you want to insert 9 rows
you don't need the inputbox.

look for InsertBlankRows() Ken Wright, 2003-08-09
http://www.mvps.org/dmcritchie/excel/insrtrow.htm

Not using a full name to identify yourself is not very friendly, in my opinion.
It also makes it hard to identify your own postings in the archives by
your email address or even by your name.
Email and privacy (for those who don't use email address)
http://support.microsoft.com/newsgroups/default.aspx
Searching newsgroups:
http://www.mvps.org/dmcritchie/excel/xlnews.htm

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Jeff" wrote in message ...
Let's say I have a spreadsheet in which a unique number
is entered into column A, rows 1 through 5.

Column A
Row 1 100
Row 2 200
Row 3 300
Row 4 400
Row 5 500

I need a macro that will insert 9 rows after each entry,
copying original value. To further clarify, the macro
needs to read the value of cell 1A (100), and then insert
9 rows underneath containing the same value (100). I need
this done for all 5 original rows. Thanks.





All times are GMT +1. The time now is 06:51 AM.

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