Excel insert row (formatting ?) :: 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 (formatting ?)
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

dawnfoss
Board Regular


Joined: 23 Apr 2002
Posts: 69


Status: Offline

 Reply with quote  

Is there an easy way to insert rows into a spreadsheet at set intervals? Ie , i need to add a row after every 11th line on an 800 line spreadsheet. The convential way of clicking on the row and then inserting a row is a bit much because of the size of the sheet.
Thanks!
DAwn F

Post Tue Jan 21, 2003 6:33 pm 
 View user's profile Send private message

jmiskey
Board Master
Board Master


Joined: 02 Aug 2002
Posts: 3111

Flag: Usa

Status: Offline

 Reply with quote  

You code run a simple macro, like below:

code:

Sub MyInsertRows()

    Range("A1").Select
    For i = 1 To 73
        ActiveCell.Offset(11, 0).Select
        Selection.EntireRow.Insert
        ActiveCell.Offset(1, 0).Select
    Next i
   
End Sub




I am looping through 73 times because 800 / 11 =72.7.

Hope this helps.

Post Tue Jan 21, 2003 7:27 pm 
 View user's profile Send private message

dawnfoss
Board Regular


Joined: 23 Apr 2002
Posts: 69


Status: Offline

 Reply with quote  

THANK YOU!!!!

Post Tue Jan 21, 2003 7:33 pm 
 View user's profile Send private message

Richie(UK)
MrExcel MVP


Joined: 18 May 2002
Posts: 2434
Location: Worcester, England
Flag: Uk

Status: Offline

 Reply with quote  

Too slow I know, but as I've written it I might as well post it icon_smile.gif.

Sub RowInsertTest()

Dim rw As Long, i As Integer

rw = Worksheets("Sheet1").Range("A65536").End(xlUp).Row
'the last used row in column A
i = 11
'the number of rows between inserts

Application.ScreenUpdating = False
Do Until rw <= 1
If rw Mod i = 0 Then
Rows(rw).Offset(1, 0).Insert
rw = rw - 1
Else: rw = rw - 1
End If
Loop
Application.ScreenUpdating = True

End Sub



_________________
Richie

Post Tue Jan 21, 2003 7:48 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.