+ Reply to Thread
Results 1 to 9 of 9

Filter - VBA MAcro

  1. #1
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Filter - VBA MAcro

    Hi All,

    I saw this file that will filter based on the given criteria. Its completely working with text however, i have to filter it by numbers. When i remove the ' in the numbers then i encountered errors.

    Can someone help me how to address it in the code below? The criteria that i will be using will be numbers...

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Filter - VBA MAcro

    Try making it so all the values in your arrays are 'strings'..

    Check the value of the vCrit array in your Locals window with your existing code and then check it when you apply the code i just gave you..

    Change this:

    Please Login or Register  to view this content.
    To this:
    Please Login or Register  to view this content.
    The fact that i used Chr(34) is inconsequential.. you could use any delimiter... like:

    Please Login or Register  to view this content.
    Last edited by apo; 03-19-2015 at 09:15 AM.

  3. #3
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: Filter - VBA MAcro

    Hi Apo,

    I have changed the code but only the first criteria in the lists sheet is shown. The second criteria is not included in the filter evern though it exist.

    Attached is the file.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Filter - VBA MAcro

    I do not think filter works well with numbers as you have already find out yourself. Possible solution is to copy the column you want to filter in to separate column and change this column in to text, filter it and then delete this temp column.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Filter - VBA MAcro

    If you wish to filter for numbers you need to change this line

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    then you can filter for numbers.

    Alf

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Filter - VBA MAcro

    You have not removed your autofilter line of code.. so it is getting the correct result with the 2 lines of code i gave you and then your original autofilter line is then getting applied.

    Always handy to step through your code with F8 to see how it works.

    This line needs to be removed:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: Filter - VBA MAcro

    Hello, apo. I Still cant get it working even though i have removed it.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Filter - VBA MAcro

    ok.. here is the code..

    I have added it into your Original Workbook you attached.. works here..

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: Filter - VBA MAcro

    Thanks Apo!

+ 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] I need formula or macro to filter a number of items from different tables at single filter
    By Karthikeyannb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2014, 11:04 AM
  2. Replies: 5
    Last Post: 12-19-2013, 06:58 AM
  3. Filter Macro (range contained in filter value)
    By antman10 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2010, 11:09 PM
  4. Advanced Filter Macro - Won't run the filter
    By dsil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2008, 11:59 AM
  5. Need macro to filter, create tab on filter and copy/paste
    By Jen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2006, 11:50 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