+ Reply to Thread
Results 1 to 6 of 6

Macro to hide rows (Auto filter) based on multiple criteria

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Macro to hide rows (Auto filter) based on multiple criteria

    Hi,

    I have searched online for a macro that would do this but found no luck.

    What I want to do is identical to a simple filter but if possible I would like this to be a macro which is constantly running and would update based on cell criteria.

    The two input cells on the attached are:
    AB6 (The Project)
    AF6 (The resource)

    What I would like is the rows hidden (from and including row 9 and below) hidden if they do not match the criteria

    e.g. if Project 2 and Person 2 is selected then it would only show row 18
    e.g. 2 if Project 3 is selected (and resource left blank) it would show only rows 25-32

    Can anyone help with the code?

    If possible I need it to run all the time but if need be I can create a button
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro to hide rows (Auto filter) based on multiple criteria

    Srtick the following in a module
    Please Login or Register  to view this content.
    Then run the module (passing the cell values to it) whenever either of the two cells are changed.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to hide rows (Auto filter) based on multiple criteria

    • Right-click on the sheet tab
    • Select View Code from the pop-up context menu
    • Paste the code below the the worksheet's code module


    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 10-29-2014 at 12:20 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Macro to hide rows (Auto filter) based on multiple criteria

    Hi,

    Thanks for both these codes - I couldnt get PJ's to work but AlphaFrogs has done the job - thank you!

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Macro to hide rows (Auto filter) based on multiple criteria

    Hi,

    I know I marked this post as solved but I have a new requirement..

    The code:
    Please Login or Register  to view this content.
    Could this also include a feature where in cell Z6 if it contains a number and if column H is equal to or greater than that number it would hide them rows.

    On my model I have a lot of zeros so if I put a "1" in cell Z6 Id like to hide the zeros.

    Again if its blank then show all

  6. #6
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Macro to hide rows (Auto filter) based on multiple criteria

    Hi - Can anyone help with this please?

+ 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. Macro to hide rows based on today's date and auto run it
    By evt123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2014, 01:14 PM
  2. VBA Code for Multiple criteria auto Filter & sending the mails based on that
    By Rajveer1981 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-09-2012, 01:37 PM
  3. Excel Macro/ VBA that can hide rows based on multiple criteria
    By hody in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 09:04 AM
  4. Macro - Hide/Unhide Rows based on conditional criteria
    By cklein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2012, 02:23 PM
  5. [SOLVED] Macro Filter to hide rows based on Drop Down List
    By dieseldogpi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2012, 11:19 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