+ Reply to Thread
Results 1 to 8 of 8

Auto filter list by form selection, VBA

  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    Pandrup, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Unhappy Auto filter list by form selection, VBA

    Hi Everyone.

    I’m new in using VBA in Excel, and this is my first "copy paste code". I want to use selections in forms to auto filter a list. I found this VBA code here, http://www.ozgrid.com/forum/showthread.php?t=91151 which does exactly what I need, but combined with forms, it doesn’t update.

    I put my workbook here http://www.ferlev.dk/off/Sort_list_by_selection.xls

    The cells I’m referring to are B29 & C29. Also I have no clue if the copied VBA code is okay. Is there a basic VBA guide somewhere in here?

    Any help would be appreciated!

    [I have theid to get an ansfer here (crosspost I guess) http://www.mrexcel.com/forum/showthr...88#post2003988 , without any replies ]

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Auto filter list by form selection, VBA

    The problem is the cell linkage does not cause the worksheet_Change event to fire.

    The calculate event fires so you can put your code in there.
    If you use a couple of variables to store filter selections you can stop it running too many times.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    07-27-2009
    Location
    Pandrup, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Talking Re: Auto filter list by form selection, VBA

    Andy,

    Thx m8. You are a genius. I guess this isent the first time something like this have been made.

    I am truley thankfull!

  4. #4
    Registered User
    Join Date
    07-27-2009
    Location
    Pandrup, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Red face Re: Auto filter list by form selection, VBA

    Andy,

    I now realise I'm missing the option to disable/show all my list items ex. when selecting an input field called "Show all" or something similar. How is this done?

    Any help are appreciated

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Auto filter list by form selection, VBA

    If you add a category to the end of your lists, which is a "*", then you can use this code.
    Note the asterisk can be replaced with text such as Show All

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-27-2009
    Location
    Pandrup, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Auto filter list by form selection, VBA

    Andy,
    Thank you so much for your prompt reply!
    I tried the code, but when selecting “*” it gives me autofilter 40 on ODSize.
    Wouldn’t I need another expression in the if sentence?
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Auto filter list by form selection, VBA

    See attached.
    Does this still give you the problem you described?
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-27-2009
    Location
    Pandrup, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Auto filter list by form selection, VBA

    Andy,
    Thx again. Works great. Now I will have to finish the inputs constraints needed for us.
    You have been a great help! Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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