I have a macro to delete rows based on cell values and I've done it for 3 columns. For it to complete all the steps, I have to run the macro 3 times. What am I missing to get this to complete all the steps when I run the macro only once?
Here is my macro:
Sub DCIFCleanup()
'
' DCIFCleanup Macro
' Cleans up Working DCIF by deleting ELOCS, 2nds, Unpaid balances < $50k and loans delinquent more than 30 days.
'
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("J2:J3000"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "ELOC LOANS" _
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
Set rng = Intersect(Range("E2:E3000"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) > 30 _
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
Set rng = Intersect(Range("K2:K3000"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < 50000 _
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
Please help.
THANKS!
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. I have added code tags because it is your first post (rule #3). I also suggest indentation of your code to reflect the structure. --6SJ
Bookmarks