Insert row after every two rows :: MrExcel Message Board



 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Insert row after every two rows
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Jillbeirne
Board Regular


Joined: 17 Sep 2003
Posts: 7

Flag: Blank

Status: Offline

 Reply with quote  

Insert row after every two rows

...beginning with A4. This would save me so much time if i had a macro that could do this! I dont know how to edit the macro i have that inserts a row after every row to perform this new task.

Any thoughts! this message board is the BEST!

thanks to all..

-J

Post Fri Sep 19, 2003 9:10 pm 
 View user's profile Send private message AIM Address

DRJ
Board Master
Board  Master


Joined: 18 Feb 2002
Posts: 1022
Location: California
Flag: Usa

Status: Offline

 Reply with quote  

Re: Insert row after every two rows

Try this

Modify as needed

Sub InsertIT()

x = 4 'Start Row

Do

Range("A" & x).Insert
x = x + 3

Loop While x < 1000 'change for more inserted rows

End Sub

Post Fri Sep 19, 2003 9:30 pm 
 View user's profile Send private message Send e-mail

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

Re: Insert row after every two rows

Hi Jillbeirne:

The following macro will insert a row every secod row -- that is it will insert a row above row4, then row6, then row8, and so on till row16 ...

code:

Sub yTest01()
    For i = 4 To 16 Step 2
        Cells(i, 1).EntireRow.Insert
    Next i
End Sub



Is this what you are looking for? If your requirements are different, please post back and then let us take it from there.
_________________
Regards!
Yogi Anand

Post Fri Sep 19, 2003 9:38 pm 
 View user's profile Send private message

Jillbeirne
Board Regular


Joined: 17 Sep 2003
Posts: 7

Flag: Blank

Status: Offline

 Reply with quote  

Re: Insert row after every two rows

Thanks for the help! DRJ, was wondering how to insert rows instead of just insert cells after every two; its seems only to be inserting breaks in column A! Thanks so much,

-Jill

Post Sun Sep 21, 2003 2:36 pm 
 View user's profile Send private message AIM Address

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

Re: Insert row after every two rows

Hi Jill:

Try the following ...

code:

Sub yTest01()
    j = 0
    For i = 4 To 16 Step 2
        j = j + 1
        Cells(i + j, 1).EntireRow.Insert
    Next i
End Sub



The above macro will insert a row starting with the 5th row and then insert another row after every two rows. Please post back if it works for you now -- or explain a little further and then let us take it from there.
_________________
Regards!
Yogi Anand

Post Sun Sep 21, 2003 3:15 pm 
 View user's profile Send private message

CartoonGal
Board Regular


Joined: 21 Sep 2003
Posts: 9

Flag: Blank

Status: Offline

 Reply with quote  

Re: Insert row after every two rows

YOGI thank you so much!


this macro did exactly what i wanted it to do!

Genius genius genius!

-Jill

Post Sun Sep 21, 2003 9:30 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.