+ Reply to Thread
Results 1 to 7 of 7

VBA to control filters by manual entry

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    Halifax, Canada
    MS-Off Ver
    Excel 2007
    Posts
    15

    VBA to control filters by manual entry

    Hi All,

    I'm working on a spread sheet that only shows data entries in a table based on data entered in by the user. I created an example using airline arrival and departure times.

    What I want to do is have the user select the Airline they want information on from a drop down list of all the airlines. That turns on a filter which shows only the data for the airline selected. I got this working already as you will see in the sample sheet.

    The next part is more tricky. There are 3 other cells below the airline selection cell. The first is threshold. I would like this to control column F which is the detention time of the aircraft. So if it is set to 0:30:00 it will filter out any flights that were not in detention for less than 30 minutes.

    The other two cells set the date range for the data. Cell B3 should filter out any dates before (less than) its value, and allow everything greater than (after) its value in the arrival column.

    Cell B4 is the opposite as it is the departure date and time. It should filter out anything from the departure column that is after (greater than) and allow anything that is before (less than) it in the filter for that column.


    Any help is much appreciated!

    Thanks,

    Neo
    Attached Files Attached Files
    Last edited by NeoPhyx; 06-04-2010 at 08:00 AM. Reason: Solved

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA to control filters by manual entry

    Perhaps something along the lines of:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 06-04-2010 at 02:44 AM. Reason: needless variable declaration (rngCell - not used)

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VBA to control filters by manual entry

    This might be worth a try

    It is activated by changing the Airline Name by selecting from the dropdown list

    Probably needs a bit more error trapping.

    Please Login or Register  to view this content.

    Hope this helps
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA to control filters by manual entry

    Marcol, per the earlier code IMO it is always worth toggling Events & Calculation whenever modifying AutoFilters as altering row visibility is a Volatile action.
    (ie with each filter operation events/calculations would otherwise be invoked [as deemed nec. by XL - rather than calculating after all had been adjusted])

    Probably worth adding that it was my belief that any manual entry within range B1:B4 was to affect the filters - not just B1 - hence the additional differences from the above.
    Last edited by DonkeyOte; 06-04-2010 at 02:45 AM. Reason: typo

  5. #5
    Registered User
    Join Date
    05-25-2010
    Location
    Halifax, Canada
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA to control filters by manual entry

    Thanks guys. Donkey that code worked amazingly for what I was looking to do. Thanks very much.
    Neo

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VBA to control filters by manual entry

    Try this

    I have added dymamic listings in a new sheet, popup calendars and input forms.

    DonkeyOte
    Took on board what you said, please have a look if you have time.

    New file appended

    [EDIT]

    corrected lines to
    Please Login or Register  to view this content.
    To include all of the departure day

    Also I think
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.
    and have used the latter in the code.
    Just change the operator in two lines in the code, if I am wrong

    Cheers
    Alistair
    Attached Files Attached Files
    Last edited by Marcol; 06-04-2010 at 09:09 AM.

  7. #7
    Registered User
    Join Date
    05-25-2010
    Location
    Halifax, Canada
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: VBA to control filters by manual entry

    Wow. That's slick. Great stuff there. Thanks a bunch.

    Neo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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