carlosab
asked on
VBA coding
I get a "Run Time Error 91 - Object variable or With block variable not set" at Line 24 when I run the below code. What is my mistake? Thanks.
Private Sub DeleteRowsWithSmallAmountAtIssue()
' Delete rows that have a value of Delete in Column B.
Dim rng1 As Range
Dim rng2 As Range
Dim lngRow As Long
'Application.ScreenUpdating = False
If [b2] <> vbNullString Then
Set rng1 = Range([b2], [b1].End(xlDown))
Else
Set rng1 = [b1]
End If
For lngRow = rng1.Rows.Count To 2 Step -1
If (Cells(lngRow, "B") = "Delete") Then
'Rows(lngRow).EntireRow.Delete
If rng2 Is Nothing Then
Set rng2 = Rows(lngRow)
Else
Set rng2 = Union(rng2, Rows(lngRow))
End If
Else
' If Left$(Cells(lngRow, "c"), 2) <> "CV" Then Rows(lngRow).EntireRow.Delete
End If
Next
rng2.EntireRow.Delete
Application.ScreenUpdating = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER