+ Reply to Thread
Results 1 to 7 of 7

Advancedfilter with multiple criteria?

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    579

    Advancedfilter with multiple criteria?

    Can I use vba advancedfilter to work with more than one criteria?

    I presently have one range designated. At the top cell has the field, or column, header name being "Student", then followed by a list of 6 people, located in Sheets("Extract").Range("A1:A7"), which is then extracted from Sheets("Complete").Range("tblPrimary[#ALL]") to Sheets("Extract").Range("AA1") as in:

    Please Login or Register  to view this content.
    I want to also be able to filter out a specific month, whose field/column name just happens to be "Month", but I suspect I will need to change it to "InfoMonth" or the like to avoid the probable key word of "Month"...

    The months are numerical in those fields - 1 through 12.

    Can I add to the present filtering line or do I need to then create an additional filter?

    Thank-you for your help!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Advancedfilter with multiple criteria?

    You could add it to the existing filter.
    As far as VBA code goes, it's just a matter of including the expanded criteria range e.g.;
    Please Login or Register  to view this content.
    The harder part is what you actually put in the criteria range. Here's a good Advanced Filter tutorial if you need it.
    Advanced Filter: Criteria
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    579

    Re: Advancedfilter with multiple criteria?

    Thank-you VERY much for the tutorial; about to go there. Had thought of how you did this but then if column B has in B1 "InfoMonth" and B2 is "January", I am pretty certain that B3 through B7 are going to totally mess things up, unless, maybe I put "January" in all of them... Maybe then I could also adapt it to work with month ranges less than or equal to a half year?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Advancedfilter with multiple criteria?

    Quote Originally Posted by brucemc777 View Post
    Thank-you VERY much for the tutorial; about to go there. Had thought of how you did this but then if column B has in B1 "InfoMonth" and B2 is "January", I am pretty certain that B3 through B7 are going to totally mess things up, unless, maybe I put "January" in all of them... Maybe then I could also adapt it to work with month ranges less than or equal to a half year?
    I really don't know what criteria you want? So I can't say.

  5. #5
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    579

    Re: Advancedfilter with multiple criteria?

    Simple: Six names and one month. But I think I have two fixes: either repeating the same month for all six cells in the second column or splitting the range as in Range("B1:B7, C1:C2")

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Advancedfilter with multiple criteria?

    Quote Originally Posted by brucemc777 View Post
    Simple: Six names and one month. But I think I have two fixes: either repeating the same month for all six cells in the second column or splitting the range as in Range("B1:B7, C1:C2")
    Sounds like you're on the right track.

  7. #7
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    579

    Re: Advancedfilter with multiple criteria?

    For everyone's reference who have yet to travel this path, unless I missed something in my tests, we MUST write the range as one contiguous area within the parenthesis - it has to be ("A1:C12") , it can not even be ("A1:A12, B1:B12, C1:C12"), which blows my ("A1:A12, C1:C2") out of the water, but I am still able to populate B1:B12 with the exact same month and C1:C12 with the exact same year, and then with ("A1:C12") it all works!

    I still have some permutations on how to present the criteria range to experiment with, but given the results so far I do not have much hope in them. Will advise if I have any luck for all who come here, and much appreciation to AlphaFrog.

+ 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] VBA AdvancedFilter Three Criteria
    By goss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2014, 08:17 AM
  2. excel 2010 vba - advancedfilter returning ALL rows, not just criteria ones?
    By wyattea in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2013, 02:36 AM
  3. AdvancedFilter with no criteria
    By opopanax666 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2007, 08:35 AM
  4. Setting a criteria in an AdvancedFilter macro
    By Wendell A. Clark in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2006, 11:20 AM
  5. [SOLVED] Advancedfilter copy in place doesn't use criteria range correctly
    By Josh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2005, 10:35 AM

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