Macro: Insert blank row variable n times

[Closed]
Report
Posts
1
Registration date
Monday August 13, 2012
Status
Member
Last seen
August 13, 2012
-
Posts
365
Registration date
Monday February 7, 2011
Status
Contributor
Last seen
September 30, 2013
-
Hello,

I am building a University Timetable. Each subject we offer occupies one row on an excel spreadsheet, we have about 200 subjects in total. Each row inlcudes a value in column M, which is how many tutorials should be scheduled. This value can be anywhere from 1 to 20, or could be blank if the subject has no tutorials.

I would like an excel macro which inserts n number of rows under each row, where n is the value in column M.

Ideally it would cycle through each subject inserting n rows based on column M, all the way to the bottom.

Kind thanks if you can help


1 reply

Posts
365
Registration date
Monday February 7, 2011
Status
Contributor
Last seen
September 30, 2013
120
use following Codes:

for I = 1 to n
Selection.Offset(1, 0).EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove ' you can use Range reference instead of selection.

next i
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month