+ Reply to Thread
Results 1 to 9 of 9

Auto Filtering based on Cell Value? Code Required.

  1. #1
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Question Auto Filtering based on Cell Value? Code Required.

    Hello,

    I'm trying to obtain VMA code to auto filter based on the value of a static cell.

    My data is in cells A5:AH169000 with the headings on from A4:AH4.
    The cell I want to auto filter on is D2.
    The column I want filtered is AF.
    Sheet name = Contracts

    eg. If I type "12345" into cell D2, column AF will automatically filter by "12345".

    The data itself is obtained from a Access Query, which I update using a macro button (Not sure if that affect anything).

    If anyone could help me out, I'd be very grateful!

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Auto Filtering based on Cell Value? Code Required.

    Right click the sheet tab, choose View Code and paste this in:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: Auto Filtering based on Cell Value? Code Required.

    Thanks romerstomper

    Code work perfectly, however as this data comes from an access download the amount of rows will not always be ~169k.
    How can I get around this?

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Auto Filtering based on Cell Value? Code Required.

    Is it linked to the access data - i.e. is it a Table in Excel that queries the access DB?

  5. #5
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: Auto Filtering based on Cell Value? Code Required.

    We have a program which dumps the data into access and I've pulled it into excel via Data Tab > 'Get External Data' > 'From Other Sources' > 'From Microsoft Query'.

    Therefore the amount of rows is going to be different each time I click the data update button.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Auto Filtering based on Cell Value? Code Required.

    In that case it should be a Table, so try this:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: Auto Filtering based on Cell Value? Code Required.

    Amazing, works perfectly.

    Just one last thing, if cell D4 is empty, the table displays no data. Am I able to change this so there is no filter and all data is displayed?

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Auto Filtering based on Cell Value? Code Required.

    Assuming you meant D2 not D4:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: Auto Filtering based on Cell Value? Code Required.

    Brilliant.

    Thanks for your help

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Auto Filtering based on Cell Value? Code Required.

    Glad to help. Please don't forget to mark the thread solved using the Thread Tools link at the top of the page.

+ 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. auto filter event code based on cell two cell value
    By njan1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2013, 09:02 AM
  2. VBA Code for Auto filtering the most recent date
    By jgbug18 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2012, 06:47 PM
  3. Auto select yes line required in macro code - tried suggestions found on net to no avail
    By Andrew E Smith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2012, 09:25 AM
  4. auto filtering of sheet based on cell combination
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-11-2012, 02:43 AM
  5. Dynamic Auto filtering based on criteria
    By wannabeMVP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2005, 12:44 PM

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