Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula to insert lines

Status
Not open for further replies.

JICDB

Technical User
Apr 7, 2004
15
US
We have an imported document that we will be bringing into Excel which has 3000+ lines of data. We want to insert a blank line after each line of data and would like to use a formula to do it instead of manually inserting lines. If we have to we can record a macro the first time we do this but it seems like there would be an easier way.
 
Here is a macro that should do the trick. It will insert a row for each line of data you choose. For example, if you highlight A1 to A6, it will insert one row for each of those lines.

Code:
Sub insert_row()
Application.ScreenUpdating = False
On Error Resume Next
Dim nrow As Integer
Dim insrow As Range
With Selection
    nrow = Selection.Row
    [a1] = nrow
End With

For Each insrow In Selection
    nrow = nrow + 1
    Range(nrow & ":" & nrow).Select
    Selection.Insert Shift:=xlDown
    nrow = nrow + 1
    
Next

Application.ScreenUpdating = True

End Sub


Mike
 
Oops, Remove this line, it's not needed:
Code:
[a1] = nrow

Mike
 
You are awesome!!!!! It works like a charm. Thanks so much for taking the time to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top