+ Reply to Thread
Results 1 to 2 of 2

VBA Autofilter Only on Existing Criteria

  1. #1
    Registered User
    Join Date
    06-22-2009
    Location
    Lincoln
    MS-Off Ver
    Excel 2003
    Posts
    68

    VBA Autofilter Only on Existing Criteria

    The title is a little misleading, so I'll explain further.

    I've been playing around with VBA (and googling the bits I couldn't do) and have managed to come up with this:

    Please Login or Register  to view this content.
    The first section filters on a single column (pulling out information between the dates I enter in cells A2 and B2). The second section filters on a separate column. And, obviously, the third section calls the first 2.

    Now, this works (Yay me) much to my surprise. I know that I should be able to add the third criteria in the section section to the first section, but I couldn't work it out, hence the 2 separate pieces.

    However, what I want is for either filter to work if the other criteria is blank. So, if the dates are blank, but the third criteria has been entered (let's say it's a location), then the filter would only look at that column. Conversely, if there is no location entered, I would like the filter to only work on the dates.

    Also, I'd like to be able to cancel the autofilter, i.e. show all.

    I've fiddled around with isempty and various other functions and have come up empty. All I end up with is the filter filtering everything out and leaving me with nothing.

    Any ideas?

    Edit: OK, skip the 'clearing' aspect. I've actually managed to add in a separate button that clears the autofilter (which I did all by myself). But I still haven't managed to get the system to filter on only one of the criteria should the other be blank.
    Last edited by jennyaccord; 06-14-2011 at 10:29 AM. Reason: New information

  2. #2
    Registered User
    Join Date
    06-22-2009
    Location
    Lincoln
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: VBA Autofilter Only on Existing Criteria

    Actually, I managed to fix it all by myself.

    It took a few hours, several cups of coffee and lots and lots of PC directed verbal abuse, but I got there in the end.

+ 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