Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default how can i create a macro that insert 2 rows

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default how can i create a macro that insert 2 rows

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)

"andresg1975" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create a control button to insert rows nadswilkes28 Excel Discussion (Misc queries) 4 May 15th 07 04:20 AM
trying to create an insert row macro jgray Excel Discussion (Misc queries) 9 March 20th 07 02:45 PM
How do I create a Macro to sort data and insert blank rows & subto karinmpfa Excel Worksheet Functions 2 April 25th 06 09:57 PM
how do I create a macro to auto insert rows? aashish Excel Worksheet Functions 1 January 30th 06 11:49 PM
[beginner] create macro to insert symbol Tom Ogilvy Excel Programming 6 July 11th 05 01:43 PM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"