+ Reply to Thread
Results 1 to 13 of 13

Hide/Unhide Rows Based On Drop Down Selection

  1. #1
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Hide/Unhide Rows Based On Drop Down Selection

    Hi,

    I've been struggling with the following:
    -I have a drop down selection on sheet 1.
    -Based upon that, a corresponding cell on sheet 2 is changed to "Passed" or "Failed".
    -The VBA code I currently have is set up to hide rows 43-46 if that value is "Failed" and have it unhide 45-48 if it is "Passed.
    -Everything works fine, accept for the fact that anytime I change ANY cell, the sheet recalculates.
    -Based upon the fair amount of entry that will take place in this workbook, this could considerably slow down the efficiency of the sheet.
    -I'm using the "Private Sub Worksheet_Calculate()" function. Should I not be? What am I doing wrong?

    Here's my code:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by QABrian; 10-13-2014 at 06:52 PM. Reason: No Code Tags

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Hi Brian,

    Welcome to the Forum We wrap our code in code tags, you only need to highlight the code and click on the # (you can just edit post #1).

    Can you upload a sample spreadsheet? Don't post anything confidential etc! Just click on Go Advanced and then the paper clip
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Sorry about the newbie faux pas and thanks for the help.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Hi Brian,

    Thanks for the rep! Try this instead:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Your very welcome. Thanks for the help.

    Unfortunately the fix didn't work. The rows will hide but not unhide. I've attached the file with your code applied to it.
    Attached Files Attached Files

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Hi Brian,

    In the sheet:

    Please Login or Register  to view this content.
    In Module1:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Unfortunately, that didn't work either. Was the first code on the sheet supposed to have something in it to call the 2 subs in the module? Either way, now the rows won't hide/unhide at all...
    Attached Files Attached Files

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    I had to fiddle with the sheet protection and, finally that worked for me. Try playing with the protection. Review - Unprotect Sheet


    In the sheet code, you'll find a TestCh - Play that by hitting F8 to single step. Among other things, it will reset your events

    AQBrian.xlsm
    Last edited by xladept; 10-14-2014 at 05:11 PM.

  9. #9
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Forgive me. Upon opening the workbook all sheets are unprotected. To do my due diligence I went through and made sure all cells were not 'locked' in formatting. Then I went and protected and then unprotected it sheets.

    Nothing.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    I edited my last post - take another look

  11. #11
    Registered User
    Join Date
    10-13-2014
    Location
    Bakersfield, CA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hide/Unhide Rows Based On Drop Down Selection

    That would be great. However, I need the rows to hide automatically just based upon the drop down selection (and subsequent PASSED/FAILED result). The TestCH is a separate macro. Perhaps it could be utilized and called on from the initial code.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Hey Brian,

    I didn't mean to use the TestCh regularly - I just meant to use it to test the Event Code - and, as a bonus, to reenable events!

    BTW - how do Passed/Failed get into that "U5"?

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hide/Unhide Rows Based On Drop Down Selection

    Since Excel is so particular:

    Please Login or Register  to view this content.
    *all that I can think of until I find the origin of the "U5" entry

+ 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] How to hide & unhide rows based on selection from drop down box?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2013, 08:30 PM
  2. Replies: 1
    Last Post: 02-01-2013, 03:06 PM
  3. macro that will hide/unhide rows based on data validation selection
    By megkim2002 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2012, 10:40 AM
  4. [SOLVED] How VB code can unhide/hide rows based on combobox selection?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 01:25 PM
  5. How to unhide rows based on drop down box selection?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2012, 05:55 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