How do I create macro to add 8 rows at a time?

G

GM

I have a worksheet with data that I need to insert 8 rows inbetween the other
rows in a spreadsheet. I tried creating a Macro but it records the cell
reference and just adds 8 rows at the same spot.
 
G

Gary Brown

Range(ActiveCell.Address & ":" & _
ActiveCell.Offset(7, 0).Address).Insert _
Shift:=xlDown
will insert 8 rows starting at the cursor.
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown
 
S

StumpedAgain

My guess is that you're only inserting a row for a particular cell. Try this:

Range("B5").EntireRow.Insert shift:=xlDown
 
G

Glenn

GM said:
I have a worksheet with data that I need to insert 8 rows inbetween the other
rows in a spreadsheet. I tried creating a Macro but it records the cell
reference and just adds 8 rows at the same spot.

From the help file...

If you want the macro to run relative to the position of the active cell, record
it using relative cell references. On the Stop Recording toolbar, click Relative
Reference so that it is selected. Excel will continue to record macros with
relative references until you quit Excel or until you click Relative Reference
again, so that it is not selected.
 
G

Gary Brown

You're absolutely right! Insert rows example below...

Range(ActiveCell.Row() & ":" & _
ActiveCell.Offset(7, 0).Row).Insert _
Shift:=xlDown

--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top