double spacing

cmefly

Well-known Member
Joined
May 13, 2003
Messages
683
how do i double space my excel worksheet? basically add rows between two rows....is there a macro for this?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Code:
Sub DoubleSpace()
Dim LastRow As Integer
LastRow = Range("A65536").End(xlUp)
For i = 1 To (LastRow * 2) Step 2
Rows(i + 1 & ":" & i + 1).EntireRow.Insert
Next i
End Sub

this should work for you

hth
kevin
 
Upvote 0
Kevin, your code will not work because you need to use Long instead of Integer for numbers greater than 32,767. Also, there needs to be .Row added after the Range definition. And if Option Explicit is at the top of the module, the i Integer should be declared to avoid a run time error.

Sub DoubleSpace()
Dim i As Integer
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
For i = 1 To (LastRow * 2) Step 2
Rows(i + 1 & ":" & i + 1).EntireRow.Insert
Next i
End Sub
 
Upvote 0
Code:
Sub DoubleSpace()
  For i = Range("A65536").End(xlUp).Row To 1 Step -1
    Range("A" & i).EntireRow.Insert xlShiftUp
  Next i
End Sub

This works also!
 
Upvote 0
It's generally better to loop backwards when inserting rows:

Code:
Sub Test()
    Dim x As Long
    Application.ScreenUpdating = False
    For x = Range("A65536").End(xlUp).Row To 1 Step -1
        Cells(x, 1).EntireRow.Insert
    Next x
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,348
Messages
6,124,425
Members
449,157
Latest member
mytux

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