How can I insert rows alternately

N

nazir

IF I HAVE DATA ON EXCEL SHEET AND I WANT TO INSERT BLANK ROWS BETWEEN ALL THE
SELECTED ROWS, HOW CAN I DO IT.
 
M

Mike H

Hi,

Right click your sheet tab, view code and paste the code below in.
make your selection and run the code

Sub Marine()
x = Selection.Rows(1).Row
y = Selection.Rows.Count
For I = y To x + 1 Step -1
Rows(I).Insert
Next I
End Sub


Mike
 
G

Gord Dibben

It can be done using VBA but why would you want to do this?

You would not be able to sort, filter or otherwise manipulate the data.

If for appearance only, select the rows and double the height.

But if you need the inserted rows, select a bunch of rows and run this
macro.

Sub InsertALTrows()
'David McRitchie, misc 2001-06-30
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim I As Integer
For I = Selection(Selection.Count).Row To Selection(1).Row + 1 Step -1
Rows(I).entirerow.Insert
Next I
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 

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