+ Reply to Thread
Results 1 to 13 of 13

Use multiple cell values in autofilter criteria

  1. #1
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Use multiple cell values in autofilter criteria

    Good Morning!

    I'm trying to make a macro filter, but I don't know how to use multiple cells as criteria.

    I'm using this:

    Please Login or Register  to view this content.
    But the filter is using only the value in K3.

    Can anyone help me please?

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Use multiple cell values in autofilter criteria

    Plese use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting and make different than other text.

    Highlight your code and click the # icon at the top of your post window.

    I've fix it now for you.

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Use multiple cell values in autofilter criteria

    Try this:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Use multiple cell values in autofilter criteria

    Or this.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Re: Use multiple cell values in autofilter criteria

    Thanks for your help zbor and bakerman2!

    I forgot to tell this:
    The cells I want to use as criteria are in Sheet4, and the table is in Sheet3.

    Let me show you all the code:
    Please Login or Register  to view this content.
    I don't know how to mix your code with mine...

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Use multiple cell values in autofilter criteria

    Maybe something like this.
    Please Login or Register  to view this content.
    Last edited by bakerman2; 08-30-2016 at 02:10 AM. Reason: error in formula

  7. #7
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Re: Use multiple cell values in autofilter criteria

    Dank u wel / merci beaucoup bakerman2!

    I placed your macro but it shows me this error:
    "Type mismatch"

    Any idea?

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Use multiple cell values in autofilter criteria

    Hard to say without seeing example file to test on.

  9. #9
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Re: Use multiple cell values in autofilter criteria

    Hello Bakerman2

    I've upload a very simple exemple to make you know what I want.

    The result I am searching for is the one you can see in Sheet2

    Thanks in advance for your help!
    Attached Files Attached Files

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Use multiple cell values in autofilter criteria

    Sorry for late response.
    This works in your example file.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Re: Use multiple cell values in autofilter criteria

    Hello Bakerman2!

    Thanks for your help!
    I need to replace your code with mine and see how can it work.

  12. #12
    Registered User
    Join Date
    07-08-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    15

    Re: Use multiple cell values in autofilter criteria

    Hello Bakerman2!

    I replaced correctly your code and it works perfectly!

    Thank you so much!

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Use multiple cell values in autofilter criteria

    You're welcome.

+ 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] How to return multiple values to a single cell based on multiple criteria
    By lwallace in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2014, 06:32 AM
  2. Autofilter multiple columns with multiple string criteria
    By svalentine91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-23-2013, 11:26 AM
  3. VBA Autofilter multiple criteria
    By Daduka in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2013, 08:36 AM
  4. Aggregate multiple values into one cell based on multiple criteria using VBA
    By jwestover1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2013, 01:17 PM
  5. [SOLVED] Autofilter with multiple criteria - how to ignore blank criteria
    By MOONDRIFT47 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2012, 12:20 PM
  6. Multiple Criteria for Autofilter using And & Or
    By Wongadob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2011, 01:39 PM
  7. multiple column , multiple criteria autofilter sort
    By jseufert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2009, 06:18 PM

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