Macro: Insert blank row variable n times

Closed
hrvatski Posts 1 Registration date Monday August 13, 2012 Status Member Last seen August 13, 2012 - Aug 13, 2012 at 09:15 PM
RWomanizer Posts 365 Registration date Monday February 7, 2011 Status Contributor Last seen September 30, 2013 - Aug 16, 2012 at 01:22 AM
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 response

RWomanizer Posts 365 Registration date Monday February 7, 2011 Status Contributor Last seen September 30, 2013 120
Aug 16, 2012 at 01:22 AM
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