Macro: Insert blank row variable n times

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


Related:

1 response

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