delete every X row, insert everyY row

  • Thread starter Thread starter elaine216
  • Start date Start date
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.
 
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)
 
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.
 

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

Back
Top