+ Reply to Thread
Results 1 to 8 of 8

Unhide and Hide row(s) based on value in a cell in the row above

  1. #1
    Registered User
    Join Date
    01-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Angry Unhide and Hide row(s) based on value in a cell in the row above

    Am pretty new to vba.

    Row 14 will be hidden by default.
    Am trying to automatically trigger the unhiding of row 14 based on the value in cell E13, which can have only Yes or No or can be blank.

    So if cell E13 is blank or "Yes" then do nothing .. i.e. don't unhide row 14
    But if cell E13 is "No", then unhide row 14.

    I want the macro to trigger automatically, based on user entry in cell E13. (without a button to manually trigger).

    I have searched other answers and have tried to adapt the closest ones to my problem but no success.

    Any help - specially with sample code -will be appreciated.

    thanks

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Welcome to the forum!

    Right click the sheet's tab, View Code, and paste:

    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 01-17-2014 at 11:37 PM.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Hi jammi and welcome to the forum,

    Find the attached with code behind the Worksheet. This makes the code only work on that worksheet and it is called EVENT code. It fires when stuff happens on this worksheet. The code looks like:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    01-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Thanks Ken, that worked seamlessly.

    appreciate your quick reply.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2407 Win 11 Home 64 Bit
    Posts
    24,084

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Registered User
    Join Date
    01-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Thanks, Marvin.
    This works too.
    Actually, my worksheet has several such conditional un-hiding of rows required, and I thought if I get the code /pointers for one instance I could repeat it for other instances.
    Keep in mind though that the trigger for unhiding is not the same.
    For, example a YES in E11 triggers un-hiding of row 12
    while a NO in E13 triggers un-hiding of row 14 (as per my original post for which your solution as well as Ken's solution works.

    As I guess, I can have only one Worksheet_change macro, I need to define all these cells (E11 and E13 as targets and give the different cases for the triggers.

    Any help with this will be appreciated.

    Regards,

    Jammi

  7. #7
    Registered User
    Join Date
    01-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Thanks Alan.
    I had a follow up question so will mark this thread SOLVED once I get the solution to that.
    Regards,
    Jammi

  8. #8
    Registered User
    Join Date
    01-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Unhide and Hide row(s) based on value in a cell in the row above

    Hey Marvin,

    Figured out that I had to only repeat the IF-EndIF sequence for each of the cells where I have the triggers.

    Thanks for all the help guys.

    Regards,

    Jammi

+ 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. [SOLVED] Hide/Unhide Columns based on Cell Value
    By dberg in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-26-2013, 03:36 PM
  2. how To hide/unhide rows based on cell value
    By novice2430 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 06-05-2013, 01:39 PM
  3. Hide/Unhide Rows Based On Cell Value
    By ZooTV92 in forum Excel General
    Replies: 5
    Last Post: 09-05-2011, 07:51 AM
  4. hide/unhide rows based on cell value
    By alexandruc in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 10-12-2009, 06:49 AM
  5. Hide or Unhide Column Based on Cell Value
    By ChrisR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2006, 06:10 PM

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