+ Reply to Thread
Results 1 to 7 of 7

2010VBA AutoHide(&unhide) rows based on dynamic cell value

  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Hello,

    New member and first time post. Intermediate Excel user, complete VBA novice.

    Goal:

    I have a workbook that has several sheets. In sheet1, there are inputs that determine whether Column A in other Sheets has a 0 or 1 in it. I need a VBA code that will autohide the each row that Column A has a 0 in. Autofilter would work fine except this workbook will be used frequently and the cells in column A will change from 1 to 0 and back, and I can't get Autofilter to be dynamic as needed. (once hidden, if the hidden cell changes back to a 1, it doesn't automatically unhide). Can I get the VBA code to work for the entire workbook? Or would I need to insert it into each Sheet's respective VBA input?

    Other Details:

    Column A isn't very long with 80 cells or so being referenced (usually no more than 30 rows would need to be hidden).
    Sheets2,3,n...'s Column A is based on inputs from Sheet1 which is formula driven (if that matters)

    I have attached a work-in-progress workbook that this code will be used in. All data is ficticious. 3.0 with VBA.xlsm

    Thank you very much for your time. I have searched several forums and have tried to copy/paste several different codes, but have not had any success. (some of the code froze my workbook altogether).

    I will be monitoring this thread like a hawk, if you need any additional detail, just ask.

    Thanks again,
    Shawn

  2. #2
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Bump, no response.

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Hi,

    This can be approached in a number of different ways based on need. What event would would you like to trigger the macro to run? Do you want it to change immediately as the 1 changes to a 0? If so, since Column A is a formula, what causes it to change in value?

  4. #4
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Thank you BigBas,

    The event to trigger would be anytime there is a change in those cells. I had code that was close to my needs, but updated anytime an input changed in the specific sheet, it would stutter and delay/stall (very inconvenient). The input in the workbook i have attached to this thread is based on life expectancy cells which feeds a formula to know that if that client is still alive for that respective year (row), show a one, and if the clients are both deceased (the plan ends), show a zero. All of this occurs on sheet1, but shows up on several other sheets. So to answer your question, the macro would need to update as the input changes (on sheet1) on the fly. This is why it needs to be able to unhide as well as hide.

    I hope that offers you enough information.

    Thanks.

  5. #5
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Enter the following code in the Worksheet module of the Input sheet. To open this module, in Excel, right click on the Input tab, and select view code. Enter the following code. Let me know if it works properly.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    Works Perfectly!!!

    Thanks so much BigBas. Very much appreciated.

  7. #7
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: 2010VBA AutoHide(&unhide) rows based on dynamic cell value

    You're welcome

+ 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