Solved

Insert rows programatically in excel

Posted on 2013-05-23
2
332 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 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now