Solved

Excel: Macro Formula (double If?)

Posted on 2014-11-02
2
93 Views
Last Modified: 2014-11-02
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.
0
Comment
Question by:dabug80
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40418861
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
0
 
LVL 1

Author Closing Comment

by:dabug80
ID: 40418863
Thanks for your help
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question