Need the code for a simple macro

  • Thread starter Thread starter VB MacroMan
  • Start date Start date
V

VB MacroMan

I have looked on the internet and through a couple forums for code to
insert a new row in every other row of a spreadsheet, I work with a lot
of data and sometimes the people above me will delete out the empty rows
and it makes spacing off so i cannot copy and paste anything out of it
and it gets old pasting adjusting 6000 excel rows and such.......I just
need a macro that i can click on a cell and it will insert a row under
it and from there down in every other row until an end row that i
specify.....thanx

Durst
 
Why do you need the empty rows?

If just for appearance, your life may be easier if you just delete them and set
the row heights to double the height.

But................

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

Select the rows you want then run the macro using a button or shortcut key
combo.


Gord Dibben MS Excel MVP
 
If you really need it something like this should do it:


Sub InsertEmptyRows()
Dim r1 As Range
Dim r2 As Range
Dim i As Integer
Set r1 = Application.Selection
For i = r1.Rows.Count To 2 Step -1
Set r2 = r1.Rows(i).EntireRow
r2.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next
End Sub

TZS
 

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