View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
smw226 via OfficeKB.com smw226 via OfficeKB.com is offline
external usenet poster
 
Posts: 98
Default how do i write a macro that will add rows into a spreadsheet

Hi BROCK:

This should work if you paste it into a module.

If you need any further help, please let me know.

Thanks,

Simon

Sub Row_Adder()
Dim curr_row, no_insert, start_row, exec_loop, offset, ins_stop, i As Integer

' Set the row you want the code to start running from
start_row = 20

'Set the number of rows you want to insert
no_insert = 15

'Set the number of times you want this code to run
exec_loop = 20

'Set the number of rows you want to offset each time. eg: if you
'want to insert 10 rows then move down 5 rows before inserting
'the next ten
offset = 2


'Move to the start

Rows(start_row).Select


For i = 1 To exec_loop

curr_row = ActiveCell.Row
ins_stop = curr_row + no_insert

'Select and insert the rows

Rows(curr_row & ":" & ins_stop).Select
Selection.Insert Shift:=xlDown

'select the bottom of your insert
Rows(ins_stop).Select

'move to the offset
Rows(ActiveCell.Row + offset).Select

Next i


End Sub


BROCK8292 wrote:
im trying to add 15 rows in between each row in a spreadsheet
all of which contain information i would like to use as headers
i have approximately 1600 rows in this worksheet
im assuming a macro may be the easiest way to do this but am open to any
suggestions that any of you may have
thank you for your assistance
brock


--
--------------------
Simon - UK

Email at simon22mports [ a t ] hot mail [ d ot ]com

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200704/1