how can i create a macro that insert 2 rows

A

andresg1975

how can i create a macro that selects, lets say column h, inserts two rows
every two rows.

column h

row 6 254
row 7 -254
row 8 450
row 9 -450

final result should be:

column h

row 6 254
row 7 -254
inserted row
inserted row
row 8 450
row 9 -450
inserted row
inserted row

and so on,

thanks a lot for your help
 
B

Bob Phillips

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
iLastRow = iLastRow - (iLastRow Mod 2 = 0)
For i = iLastRow To 2 Step -2
Rows(i).Resize(2).Insert
Next i

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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