+ Reply to Thread
Results 1 to 3 of 3

Runtime Error using Command Button when Worksheet is Protected

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Runtime Error using Command Button when Worksheet is Protected

    I have a worksheet containing a 'Toggle Button'. The toggle button is used to show and hide grouped columns and functions perfectly correctly, however, as soon as I protect the worksheet, clicking the toggle button generates a 'Run-time error '1004' - Unable to set the hidden property of the range class'.

    This is the code I am using to show and hide the columns.

    Please Login or Register  to view this content.
    What do I need to add to this code to prevent this problem from occuring, when the sheet is protected?

    Many thanks

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Runtime Error using Command Button when Worksheet is Protected

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Runtime Error using Command Button when Worksheet is Protected

    Hi JBeaucaire,

    That works perfectly, though I've realised that when the sheet is protect, I am unable to update a graph that also appears on the sheet!

    Is there an additional line of code that needs to be added to the Toggle Button, to allow the graph to update when data is changed via a ComboBox? Or do I need to change something specific to the graph itself?

    I tried adding Activesheet.ProtectData = False, to the Toggle Button code, but this doesn't work. I've also tried unchecking 'Locked' from the ComboBox Protection from the ComboBox Properties, so I'm unsure what I need to do to allow the graph to keep updating as the source data changes via selections made from the ComboBox. I get this error, when selecting an item from the ComboBox to update the chart, when the worksheet is protected:

    protect.jpg

    Please Login or Register  to view this content.
    Many thanks...

+ 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