Hey guys I am trying to write a code that deletes rows having values that are found using a formula. The problem is every other row is a #VALUE!
, which I cannot change due to the setup of the report. In the end I want to delete all rows that have #VALUE!
and any row that has values that are less than .75 in Column H
.
The code I tried is as shown below:
Private Sub CommandButton1_Click()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("H1:H2000"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < .75 Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Any help or tips would be appreciated.