#1   Report Post  
Posted to microsoft.public.excel.misc
asalerno
 
Posts: n/a
Default a simple macro?


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

I have a column of text and I want to insert 2 blank lines between
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 however
many times I want, but I cannot get the macro to move down 3 rows
before it inserts the next 2 blank cells.

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


--
asalerno
------------------------------------------------------------------------
asalerno's Profile: http://www.excelforum.com/member.php...o&userid=33927
View this thread: http://www.excelforum.com/showthread...hreadid=537047

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bryan Hessey
 
Posts: n/a
Default a simple macro?


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 Sub
--------------------


Hope this helps

--

asalerno Wrote:
I have been trying to write what I thought was a simple macro with no
luck.

I have a column of text and I want to insert 2 blank lines between
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 however
many times I want, but I cannot get the macro to move down 3 rows
before it inserts the next 2 blank cells.

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



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=537047

  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default a simple macro?

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.

asalerno wrote:

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

I have a column of text and I want to insert 2 blank lines between
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 however
many times I want, but I cannot get the macro to move down 3 rows
before it inserts the next 2 blank cells.

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

--
asalerno
------------------------------------------------------------------------
asalerno's Profile: http://www.excelforum.com/member.php...o&userid=33927
View this thread: http://www.excelforum.com/showthread...hreadid=537047


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple macro help chip_pyp Excel Discussion (Misc queries) 3 January 10th 06 07:57 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Simple macro please sasha New Users to Excel 1 July 19th 05 12:51 PM
Recording simple macro Dave Excel Worksheet Functions 5 July 16th 05 12:34 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 08:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"