delete every X row, insert everyY row

E

elaine216

Hi,

Just wondering is there a formula/code to delete every X th row in a
high-lighted range?

or to insert a row every Y row?

Thanks :)

elaine.
 
B

Bob Phillips

You could add a formula in an empty column

=MOD(ROW(),2)=0

and then filter that column by a value of TRUE and delete the visible rows.

, 2 gives the even rows. Change the ,2 to get other rows as the deletion
rows.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
P

PlayingToAudienceOfOne

Public Sub DeleteEveryNthRowQuickly(Optional N As Long = 2)
'The default is to delete every 2nd row
Application.ScreenUpdating = False
On Error Resume Next
With ActiveSheet.UsedRange
With .Columns(.Columns.Count).Offset(, 1).Cells
.Item(N) = True
Range(.Item(1), .Item(N)).AutoFill .Cells
.SpecialCells(xlConstants).EntireRow.Delete
End With
End With
Application.ScreenUpdating = True
End Sub


P.S. Awaiting Mr. Phillips' public ridicule.
 
Top