+ Reply to Thread
Results 1 to 6 of 6

Auto filter using selected criteria from a listbox

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    3

    Auto filter using selected criteria from a listbox

    Hi

    I am wanting to record a macro that will auto filter a data set based on multiple criteria selected from a listbox.

    As an example the listbox would have the years 2010, 2011, 2012 and 2013.

    By selecting the years 2010 and 2011 for example, I want to auto filter the year column in the data set (column A) so that it shows only 2010 and 2011.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Auto filter using selected criteria from a listbox

    Not 100% sure what you're trying to do, but maybe:
    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    08-20-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto filter using selected criteria from a listbox

    Thanks for the response but still no luck.

    I want to be able to choose from multiple criteria for the auto filter option.

    I have a data sheet with a large number of rows but column A is the year (either 2010,2011,2012 or 2013). I wanted to know if it was possible to have a list box that had a list of the years and when selected the data sheet would auto filter for those years selected. For example if only 2010 is selected only the 2010 rows in column A show or if both 2010 and 2013 are selected both the 2010 and 2013 rows in column A show.

    If this can be done better without using a list box for making the selections then please let me know.

    Thanks again.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Auto filter using selected criteria from a listbox

    I'm confused. Please see attached. The listbox is multi select and will allow you to sort by two criteria.

    Attachment 259332

  5. #5
    Registered User
    Join Date
    08-20-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto filter using selected criteria from a listbox

    Thanks again!

    It doesn't seem to filter if only 1 year is selected. Is it also possible to make it so that more than 2 years are selected (anywhere from 1 year to all of the years in the list box)? Book1.xlsm

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Auto filter using selected criteria from a listbox

    Attachment 259374

    Note, this will only filter by the top 2 criteria if more than 2 criteria are selected.

+ 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. Listbox to filter multiple criteria
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-04-2013, 12:41 PM
  2. how write to rows selected by auto/advanced filter in VBA code
    By xdalibor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2011, 11:28 AM
  3. Replies: 1
    Last Post: 10-27-2010, 05:48 AM
  4. Auto Filter on selected row
    By johnlovesbeer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2009, 05:02 AM
  5. [SOLVED] How do I obtain total for auto filter value selected ?
    By FLo in forum Excel General
    Replies: 1
    Last Post: 11-22-2005, 11:15 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