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

  • Thread starter Thread starter GM
  • Start date Start date
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.
 
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
 
My guess is that you're only inserting a row for a particular cell. Try this:

Range("B5").EntireRow.Insert shift:=xlDown
 
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.
 
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

Back
Top