Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert rows programatically in excel

Posted on 2013-05-23
2
Medium Priority
?
346 Views
Last Modified: 2013-05-24
On my work sheet I want to insert an empty row after row5  and then an empty row after every row of data until until row 107. is this possible in VBA?
0
Comment
Question by:Serena2345
2 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 total points
ID: 39192545
Yes it is. The easiest is to do a reverse loop so that you start inserting at the end and work your way back up. That way you don't need to address the fact to row 6 is now row7, row 7 is now row 9, etc.

Thomas

Sub FUNNYTETS()
Dim lLoop As Long, rgRows As Range

'turn off updates to speed up code execution
With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
End With


For lLoop = 108 To 6 Step -1

    Rows(lLoop).Insert

Next

'turn off updates to speed up code execution
With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
End With


End Sub

Open in new window

0
 

Author Closing Comment

by:Serena2345
ID: 39195642
just what I needed thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question