Solved

Insert rows programatically in excel

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

813 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

17 Experts available now in Live!

Get 1:1 Help Now