Insert a line

silverxx12

Board Regular
Joined
Jan 23, 2009
Messages
99
Hi

I have a spreadsheet with say 50 data entries

I need to insert a line between each of the data entries

Is there a quick was of doing this

I do not wish to insert 50 line indiviadually

Many thkx

Silver
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Does this do what you need:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> InsertRows()<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> i = Cells(Rows.Count, "A").End(xlUp).Row <SPAN style="color:#00007F">To</SPAN> 1 <SPAN style="color:#00007F">Step</SPAN> -1<br>            Cells(i, "A").EntireRow.Insert<br>        <SPAN style="color:#00007F">Next</SPAN> i<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
Try

Code:
Sub InsRow()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Insert
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
yes that works just fine - first time using code like this cool :laugh:

If i wanted it to insert two lines between each data line is that possible ?

thnx

Not to worry

I was a bit bold and tried googling it

came up with theis one looks really cool:

I think u r able to choose how many you wish to fill - thnx for the helps much appreciated


Sub InsertRows()
Dim rw, LastRow, inRows, numRows As Double
'Get Number of Rows to insert from User
numRows = Application.InputBox("Enter The Number Of Rows To Insert")
'Find last row with data in Column A
LastRow = Cells(65536, 1).End(xlUp).Row
'Loop through data, inserting rows
For rw = LastRow To 2 Step -1
For inRows = 1 To numRows
Rows(rw).Insert Shift:=xlDown
Next
Next rw
End Sub
 
Last edited:
Upvote 0
Is there a way to do this via the F5 key. Like removing blanks f5>blanks>/edr?

But you could assign the macro a shortcut key. Just make sure you don't use a reserved shortcut (Ctrl+C, V, X, O, P, etc.) I generally use Ctrl+Shift+Key because of that.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top