a simple macro?

A

asalerno

I have been trying to write what I thought was a simple macro with n
luck.

I have a column of text and I want to insert 2 blank lines betwee
every cell of text.

Example of what I have:

excel
excel
excel

What I want:

excel

excel

excel


I have been able to get the macro to insert 2 blank cells for howeve
many times I want, but I cannot get the macro to move down 3 row
before it inserts the next 2 blank cells.

I have tried using xldirection and offset commands with no luck. Thi
is my first time playing with macros so it's quite possible I'm no
even using the above comands correctly. Anyone have an idea
 
B

Bryan Hessey

Simply start from the end, asin:


Code
-------------------
Sub testrow()
Dim LastRow As Integer, iCtr As Integer

LastRow = Range("a65536").End(xlUp).Row
MsgBox "last " & LastRow

For iCtr = LastRow To 2 Step -1
Range("A" & iCtr).EntireRow.Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Next
End Su
-------------------


Hope this helps

--
 
D

Dave Peterson

I try not to add blank rows to my data. If you're only doing this to make it
look like the data is triple spaced, maybe just increasing the rowheight would
be enough???

But if you must....

Option Explicit
Sub testme()

Dim myCol As Long
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long

With Worksheets("sheet1")
myCol = .Range("a1").Column 'which column???
FirstRow = 1 'no headers
LastRow = .Cells(.Rows.Count, myCol).End(xlUp).Row

For iRow = LastRow To FirstRow + 1 Step -1
.Rows(iRow).Resize(2).Insert
Next iRow
End With

End Sub

When you're inserting or deleting rows, it really makes things lots easier if
you start at the bottom and work your way up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top