Inserting blank rows between each line

Tmayeux

New Member
Joined
Apr 23, 2009
Messages
10
Happy Friday Everyone.

I'm in 2007 and need to insert a row between every other line in a 30,000+ row document.

To illustrate what I need:

A1 full of data
A2 want blank row
A3 full of data
A4 want blank row

This is what I have:
A1 data
A2 data
A3 data
A4 data

I appreciate any insight. Thanks again.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hello and welcome to MrExcel.

Click the Office button (top left), click Excel Options then tick Show Developer Tab in the Ribbon and click OK.

Press ALT + F11 to open the Visual Basic Editor, Insert > Module and paste in

Code:
Sub test()
Dim i As Long, LR As Long
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Insert
Next i
Application.ScreenUpdating = True
End Sub
Press ALT + Q to return to your sheet, on the Developer tab click Macros, click on test then click the Run button.
 
Upvote 0
Tmayeux,

Try:

For Excel 2007: Click on the "Office Button" (top left), click "Excel Options", "Top Options for working with Excel", then tick "Show Developer tab in the Ribbon". Then click on the "OK" button.

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL+C
2. Open your workbook
3. Press the keys ALT+F11 to open the Visual Basic Editor
4. Press the keys ALT+I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL+V
7. Press the keys ALT+Q to exit the Editor, and return to Excel.

Code:
Option Explicit
Sub InsertRows()
Dim LR As Long, a As Long
LR = Cells(Rows.Count, 1).End(xlUp).Row
For a = LR To 2 Step -1
  Cells(a, 1).EntireRow.Insert
Next a
End Sub

Then run the "InsertRows" macro.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,324
Messages
6,124,250
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top