View Single Post
  #3   Report Post  
run, I've got the keys
 
Posts: n/a
Default

Paul,
I've attempted to use your script to insert a line every other row, but have
not been successful. I can alter it to insert a line every two rows, but
when I change line "For iCtr = 5 To LastRow Step 4" to "For iCtr = 2 To
LastRow Step 1" my table disappears.

Any suggestions?

Thank you,
Brian

"Paul B" wrote:

Pete, here is some code that will do it,

Sub testme()
'will add a row after every 4th row
'Original code by: Dave Peterson
Dim iCtr As Long
Dim LastRow As Long
Dim myRng As Range
With ActiveSheet
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set myRng = Nothing
For iCtr = 5 To LastRow Step 4
If myRng Is Nothing Then
Set myRng = .Cells(iCtr, "A")
Else
Set myRng = Union(.Cells(iCtr, "A"), myRng)
End If
Next iCtr
End With

If myRng Is Nothing Then
'do nothing
Else
myRng.EntireRow.Insert
End If
End Sub



--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Little pete" wrote in message
...
wanting to auto insert a blank line every 'x' number of lines down the

s/s.
for the example 'x' can be every 4th line

cheers pete