+ Reply to Thread
Results 1 to 6 of 6

VBA AutoFilter issue

  1. #1
    Registered User
    Join Date
    01-11-2012
    Location
    Bristol
    MS-Off Ver
    Excel 2007
    Posts
    15

    VBA AutoFilter issue

    Hi All

    I am new to excelforum, and also fairly new to VBA.
    most of my experience consists of recording macro's and reviewing the code and amending as required.

    i have an issue with a macro I am creating at the moment. The part of the code in question will (eventually) filter a tab of data and copy and paste the result onto another tab.

    Background - Each row of data is categorised into - Standard Approve, Standard Reject, Review or Exception. Lines that have not yet been categorised return #na (from a vlookup).

    After allocating the exceptions, I need the macro to re-filter to show all remaining lines excluding #NA.
    The issue I have is that, not all other categories will always have any existing lines (usually standard reject).

    The filter code i have is this:
    ActiveSheet.Range("$A$1:$S$6421").AutoFilter Field:=15, Criteria1:=Array("REVIEW", "STANDARD APPROVE", "STANDARD REJECT")

    This was done by recording me unticking the #na box in autofilter.
    Is there a way I can filter by categories, but only if they exist?

    E.G if Standard Reject contains 0 lines, ignore the filter command and continue to filter by only Review and Standard Approve?

    Any assistence would be greatly appreciated

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA AutoFilter issue

    Have you tried using "<>#N/A" as the criterion?
    Good luck.

  3. #3
    Registered User
    Join Date
    01-11-2012
    Location
    Bristol
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA AutoFilter issue

    Hi

    I read your response and really hoped it would be that easy. Unfortunately "<>#NA" does not affect the autofilter. The data remains unfiltered.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA AutoFilter issue

    Please note the forward slash in "<>#N/A"

  5. #5
    Registered User
    Join Date
    01-11-2012
    Location
    Bristol
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA AutoFilter issue

    Apologies. Works like a dream. Thanks a lot!

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA AutoFilter issue

    Not to worry - easily done. ;-)
    Pleased to have helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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