+ Reply to Thread
Results 1 to 10 of 10

Hiding/Unhiding Rows Based on Dropdown Box

  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Hiding/Unhiding Rows Based on Dropdown Box

    Hello all, this issue has been stumping me for the longest time and I would greatly appreciate your collective help.

    Situation:
    I have a worksheet that needs to hide/unhide rows based on a dropdown box (form control). The dropdown box has 3 choices. Depending on the value of the dropdown box, it will hide certain rows. However, the worksheet must be protected because there are formulas within Excel throughout the sheet and as these are being designed for another group, I'd like to have them protected to prevent accidental errors.

    Error:
    When the sheet is protected and I change the dropdown box (for example from selection 1 to selection 3), I receive a run-time error: 1004. Unable to set the Hidden property of the Range class.

    Code:
    Please Login or Register  to view this content.
    This is the partial code used. The bolded line is highlighted after clicking on debug.

    Any help would be great.

    Attachment included to help. The error is encountered any time the dropdown box is changed.
    Attached Files Attached Files
    Last edited by SubParLlama; 11-13-2012 at 02:28 AM. Reason: Attachment added

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    can u plz provide workbook with unprotected then its more easy to solve ur query.

    in that code we can call unprotect to perform assigned work and again we can call protect once the work done.

    Thanks - Naveed

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Hello SubParLlama,

    Welcome to the Forum.

    Try this,

    Please Login or Register  to view this content.
    Where Sheets("Name" = the actual sheet name, And ("PassWord" = the actual password for the Sheet, if a password does exist.

    Also see the "Please consider" note at the bottom of this post.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Registered User
    Join Date
    11-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Hello Winon. Thanks for your suggestion. I actually tried that and still continued to receive the same error.

    To Naveed Raza and everyone, I have included an attachment for reference. Again, thanks for the help.

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    And? Where is your attachment?

  6. #6
    Registered User
    Join Date
    11-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Sorry for confusion, please check first post. Attached there.

  7. #7
    Registered User
    Join Date
    11-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    I also wanted to note that I tried doing this by recording the actions using the macro recorder. When running only the macro to hide/unhide rather than triggering it from the dropdown box value, there was no error. It was only when using the dropdown box to call the hide/unhide macros that it encountered issues.

    All of this when sheet protected to begin with.

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Hello SubParLlama,

    Try the attached WorkBook now.

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Thank you very much Winon. That did it. Now time to learn how you did it. Many thanks once again.

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hiding/Unhiding Rows Based on Dropdown Box

    Hello SubParLlama,

    You are welcome.

    Thank you for the Rep.

    You have done a great piece of work, and you don't need to "learn" very hard of how your issue was resolved.

    The DropDownBox is linked to Cell G4, and G4 was not "Unlocked" before protecting the Sheet.

+ 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