Solved

Excel: Macro Formula (double If?)

Posted on 2014-11-02
2
78 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 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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
Comment Utility
Thanks for your help
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now