+ Reply to Thread
Results 1 to 9 of 9

Macro to filter multiple values in a column

  1. #1
    Registered User
    Join Date
    05-08-2018
    Location
    Philippines
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Macro to filter multiple values in a column

    Hi,

    I'm trying to create a macro that will filter multiple values using array. However, I'm not sure what is the problem on the code and it wont filter more than two values in array. Can anyone help me on this? I'm trying to filter column I if it contains "*Extra Air*", "*Extra-Air*", "*ExtraAir*", and if it does then I will tag it as Extra Air Con. The formula works for two criteria, but if i added another one, it wont work. Below is my sample code.

    Please Login or Register  to view this content.
    This has been cross-posted to mrexcel.com/forum/excel-questions/1064023-multiple-criteria-filter-vba.html"
    Last edited by jengesmeriz; 07-23-2018 at 09:31 PM.

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

    Re: Macro to filter multiple values in a column

    Deleted, OP complied to Forum Rule#3
    Last edited by bakerman2; 07-23-2018 at 06:38 AM.
    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.

  3. #3
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro to filter multiple values in a column

    Hello jengesmeriz,

    Here's one way around the array problem.

    Place your three criteria in a column out of sight (say Column X and starting in row2) then try the following code:-
    Please Login or Register  to view this content.

    It assumes that your headings are in row1 with data starting in row2.

    I hope that this helps.

    Cheerio,
    vcoolio.
    Last edited by vcoolio; 07-23-2018 at 06:47 AM. Reason: Typo.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Macro to filter multiple values in a column

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.

  5. #5
    Registered User
    Join Date
    05-08-2018
    Location
    Philippines
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: Macro to filter multiple values in a column

    Hi,

    My apology. This is surely noted. Thanks for the guidance.

  6. #6
    Registered User
    Join Date
    05-08-2018
    Location
    Philippines
    MS-Off Ver
    MS Office 2010
    Posts
    6

    Re: Macro to filter multiple values in a column

    Quote Originally Posted by vcoolio View Post
    Hello jengesmeriz,

    Here's one way around the array problem.

    Place your three criteria in a column out of sight (say Column X and starting in row2) then try the following code:-
    Please Login or Register  to view this content.

    It assumes that your headings are in row1 with data starting in row2.

    I hope that this helps.

    Cheerio,
    vcoolio.
    Hi,
    Thanks for the tips. I will try to follow your code. I'm working on several category not just "extra air con" and definitely the loop will surely help. By the way, what is "UBound"? How does it work? Thanks!

  7. #7
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro to filter multiple values in a column

    Ok jengesmeriz, I'll leave it with you.

    This line

    Please Login or Register  to view this content.
    in simple terms basically means the array is being searched from bottom (1) to top (UBound) or (LBound to UBound): the lower bounds to the upper bounds.

    Cheerio,
    vcoolio.

  8. #8
    Registered User
    Join Date
    05-08-2018
    Location
    Philippines
    MS-Off Ver
    MS Office 2010
    Posts
    6
    Quote Originally Posted by vcoolio View Post
    Ok jengesmeriz, I'll leave it with you.

    This line

    Please Login or Register  to view this content.
    in simple terms basically means the array is being searched from bottom (1) to top (UBound) or (LBound to UBound): the lower bounds to the upper bounds.

    Cheerio,
    vcoolio.
    It works! I just noticed that the loop works for more than one criteria. Thank you so much. Appreciate the help!

  9. #9
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro to filter multiple values in a column

    You're welcome.
    Glad that I could help.

    Cheerio,
    vcoolio.

+ 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] Pivot Chart - Want to filter a column with multiple values
    By Rudurk in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-23-2013, 09:45 AM
  2. [SOLVED] Edit Recorded Macro to filter column with about 200k rows based on a list of values.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2012, 03:35 AM
  3. Macro to copy and paste special values for column data and filter column data
    By ascottbag in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-10-2012, 02:15 PM
  4. Advance filter unique values for multiple files macro
    By steeeeeve in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-20-2011, 04:27 AM
  5. Macro to filter certain values in a column and delete the rest
    By willy91785 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2011, 12:23 PM
  6. filter for multiple column values
    By rgouette in forum Excel General
    Replies: 2
    Last Post: 03-10-2008, 02:08 PM
  7. [SOLVED] advanced filter macro to locate values via multiple criteria
    By jjfjr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2005, 11:35 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