Solved

# Excel: Macro Formula (double If?)

Posted on 2014-11-02
78 Views
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
``````

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.
0
Question by:dabug80

LVL 48

Accepted Solution

Rgonzo1971 earned 500 total points
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
``````
Regards
0

LVL 1

Author Closing Comment

0

## Featured Post

### Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.