ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro that double spaces rows for an entire worksheet? (https://www.excelbanter.com/excel-discussion-misc-queries/53970-macro-double-spaces-rows-entire-worksheet.html)

glaves123

Macro that double spaces rows for an entire worksheet?
 
Hello,
I regularly import data into excel and then need to double space every row
manually, or add a new empty row between each line of data manually. Does
anyone know a macro where I can highlight all of the worksheet data, run the
macro, and everything will be double spaced automatically? Thanks for any
input!
Gary

Jim Cone

Macro that double spaces rows for an entire worksheet?
 
Gary,
Give this a try...
'---------------------
Sub I_Need_Space()
'Inserts a row between every row in the selection.
'Jim Cone - San Francisco, USA - November 05, 2005
Dim rngSelect As Excel.Range
Dim lngRow As Long
Set rngSelect = Selection.Columns(1)
If rngSelect.Rows.Count = Rows.Count Then
If MsgBox("Every row is selected. Do you want to continue ? ", _
vbQuestion + vbOKCancel, " Gary's Idea") = vbCancel Then
Set rngSelect = Nothing
Exit Sub
End If
End If
Application.ScreenUpdating = False
For lngRow = rngSelect.Rows.Count To 2 Step -1
rngSelect.Rows(lngRow).EntireRow.Insert
Next 'lngRow
Application.ScreenUpdating = True
Set rngSelect = Nothing
End Sub
'-----------------

"glaves123"
wrote in message


Hello,
I regularly import data into excel and then need to double space every row
manually, or add a new empty row between each line of data manually. Does
anyone know a macro where I can highlight all of the worksheet data, run the
macro, and everything will be double spaced automatically? Thanks for any
input!
Gary


All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com