Excel: Macro Formula (double If?)

dabug80
dabug80 used Ask the Experts™
on
Hello,

Below is my current macro formula

Sheets("3 Month Letter").Select
For Idx = RowCount To 2 Step -1
    If Range("O" & Idx).Value = 2 Then
        Range("O" & Idx).EntireRow.Delete
    End If
Next

Open in new window


Currently the rows will be deleted if the value = 2. I would also like the row deleted it the row is '#N/A'. How to I append this to the above formula?

Cheers.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
Hi,

pls try

For Idx = RowCount To 2 Step -1
    If IsError(Range("O" & Idx).Value) Then
        If Range("O" & Idx).Value = CVErr(xlErrNA) Then Range("O" & Idx).EntireRow.Delete
    ElseIf Range("O" & Idx).Value = 2 Then
    Range("O" & Idx).EntireRow.Delete
    End If
Next

Open in new window

Regards

Author

Commented:
Thanks for your help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial