PC Review


Reply
Thread Tools Rate Thread

how can i create a macro that insert 2 rows

 
 
=?Utf-8?B?YW5kcmVzZzE5NzU=?=
Guest
Posts: n/a
 
      3rd Oct 2006
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Oct 2006
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" <(E-Mail Removed)> wrote in message
news:73A2433A-0915-49D9-B40A-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a Macro to sort data and insert blank rows & subto =?Utf-8?B?a2FyaW5tcGZh?= Microsoft Excel Worksheet Functions 2 25th Apr 2006 09:57 PM
how do I create a macro to auto insert rows? =?Utf-8?B?YWFzaGlzaA==?= Microsoft Excel Worksheet Functions 1 30th Jan 2006 11:49 PM
asking again, macro to insert rows =?Utf-8?B?THVrZQ==?= Microsoft Excel Worksheet Functions 12 18th Sep 2005 06:32 PM
Macro insert data, need to insert rows =?Utf-8?B?QnJhZA==?= Microsoft Excel Misc 1 28th May 2004 03:33 PM
Insert Rows Macro Todd Microsoft Excel Programming 4 2nd Apr 2004 09:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:38 PM.