+ Reply to Thread
Results 1 to 8 of 8

Unhide hidden rows in excel based on cell value

  1. #1
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Unhide hidden rows in excel based on cell value

    Hello guys,

    I am having problems with an excel macro. The thing I want to accomplish is the following: my excel has some hidden rows. Based on a cell vallue (cell B8) being either "1" or "2", "3", "4" i want certain rows to become visible. B8 is a drop down menu - if the user selects "1" I want rows 18 and 19 to appear. If the user selects 2, 3 or 4 I want row 20 to appear. Most importantly I don't want the user to have to run the macro - I want it to be executed automatically when he chooses the value of the B8 field.

    This is what I have so far, however, it does not work. Please help!

    Please Login or Register  to view this content.
    Last edited by alansidman; 10-20-2019 at 12:46 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Unhide hidden rows in excel based on cell value

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    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

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Unhide hidden rows in excel based on cell value

    try this:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Unhide hidden rows in excel based on cell value

    If Row 20 is visible and the user enters 1 in cell B8, should Row 20 become hidden?

    If Rows 18 and 19 are visible and the user enters 2, 3 or 4 in cell B8, should Rows 18 and 19 become hidden?

  5. #5
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Re: Unhide hidden rows in excel based on cell value

    Guys, thank you for your quick answers! I just figured it out! Nevertheless thank you all! Please refer below for the answer:

    Please Login or Register  to view this content.
    [/FORMULA]

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,068

    Re: Unhide hidden rows in excel based on cell value

    You can slim that down a bit like
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Unhide hidden rows in excel based on cell value

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Unhide hidden rows in excel based on cell value

    Since you are using a drop down, the only possibilities for cell B8 will be those text strings your code has delineated. Given that, I think you should be able to replace all the code you posted with these two lines of code...
    Please Login or Register  to view this content.
    Note: If the user should manually type anything into the cell, the above code will hide Row 20 and reveal Rows 18 and 19. If you don't want that to happen, then we can use Fluff13's approach, but slim it down by another 3 code lines...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 10-20-2019 at 01:39 PM.

+ 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] VBA to unhide hidden rows
    By Sam Capricci in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-14-2018, 09:09 AM
  2. 365 Excel - Cannot unhide hidden rows
    By jhmunn in forum Excel General
    Replies: 1
    Last Post: 09-26-2017, 10:41 AM
  3. Need code to hide and unhide a row based on if other rows are hidden or unhidden
    By aradov in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-20-2014, 02:06 PM
  4. How to unhide rows that are not hidden
    By amartino44 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2013, 08:09 PM
  5. How Do I Hide/Unhide Rows in Excel based on a cell Value Automatically?
    By mgarcia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2012, 05:20 AM
  6. Unhide Hidden Rows
    By bruce2444 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-08-2009, 09:53 PM
  7. Replies: 1
    Last Post: 07-19-2006, 05:45 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