View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.newusers
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Adding a loop to conditional delete code

You could speed that up by sorting first, and not looping:

Sub DelOver16VerB()
Dim myCell As Range
Dim myRow As Long
Range("F2:F10000").Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlYes
myRow = Application.Match(16, Range("F2:F10000"))
Set myCell = Range("F2:F10000").Cells(myRow + 1)
Range(myCell, myCell.End(xlDown)).EntireRow.Delete
End Sub

HTH,
Bernie
MS Excel MVP


"maw via OfficeKB.com" <u12713@uwe wrote in message news:64cdc9dbc43e6@uwe...
Hello all,

I have the following code:

Sub DelOver16()

If ActiveCell.Value = 16 Then ActiveCell.EntireRow.Delete

End Sub

What I need to do is have the code loop through cells F2:F10000 and delete
entire rows that have a value of =16.

How would I do that?

Many thanks in advance

Mark

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...l-new/200608/1