Thread
:
Delete rows less than 0
View Single Post
#
2
Don Guillett
Posts: n/a
Why not sort and delete all at once?
or without any selections
sub deletelessthanzero()
for i =cells(rows.count,"h").end(xlup).row to 2 step -1
if cells(i,"h")<0 then cells(i,"h").entirerow.delete
next i
end sub
--
Don Guillett
SalesAid Software
"John" wrote in message
...
Can this piece of code be adapted easily to delete a row when the active
cell value is less than 0?
Range("h6:h700").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Set wks = ActiveSheet
Set rngToSearch = wks.Columns(3)
Set rngFound = rngToSearch.Find("-")
If rngFound Is Nothing Then
MsgBox "No Deletions Found"
Else
Do
rngFound.EntireRow.Delete
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Reply With Quote