+ Reply to Thread
Results 1 to 6 of 6

Ignore 'If statement' if the condition equates to error - HELP!

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Ignore 'If statement' if the condition equates to error - HELP!

    I am running a macro which filters a column to show only records with "#N/A" (ie an error), and copies these to another worksheet.
    As I am aiming for no errors, there will be occasions when there is no filtered data.

    My problem is that, unless I use something like xlCellTypeVisible, when there is no data shown it still copies and pastes all the hidden records.
    And if I do use it when no filtered data, I currently get an error "No cells were found"

    I have tried many iterations of code correction and i think i'm currently blinded by staring at it so long!

    My current if statement reads as follows:


    Please Login or Register  to view this content.

    I think I might need to use some sort of On Error Resume Next statement, but I have never used these before.
    When I tried adding that before the If statement, it just ignored the criteria and tried copying hidden rows - the exact opposite of what I want.
    I'd like something that said, if this condition = error, skip over entire if statement and carry on with rest of the sub.

    Please can someone offer some help?!

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Ignore 'If statement' if the condition equates to error - HELP!

    May be like this.......
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Ignore 'If statement' if the condition equates to error - HELP!

    On error resume next will not get rid of the error if there are no visible cells.
    You need to change this line

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Ignore 'If statement' if the condition equates to error - HELP!

    Thanks sktneer - that seems to have worked.

    Thanks also to AB33, though your suggestion won't work as if there are no cells to display, there is no value to the 'If' condition.

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Ignore 'If statement' if the condition equates to error - HELP!

    You're welcome. Thanks for the feedback and rep.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Ignore 'If statement' if the condition equates to error - HELP!

    The idea of setting in this way would be for the code to jump in to the end before the auto-filter is switched on/off line so that there is nothing to copy as there are none visible cells.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula needs to check if it equates to zero and return a blank cell
    By john dalton in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-20-2014, 12:03 PM
  2. debug error at mutiple condition If statement
    By nikko50 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2014, 07:25 PM
  3. Getting an IF statement to ignore formulas
    By bobbybear in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-31-2008, 10:37 PM
  4. If statement (Ignore blank)
    By lisadang in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2008, 12:19 AM
  5. [SOLVED] i am trying to use a formula that accepts equates words to a cost
    By Ma10mus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 06:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1