+ Reply to Thread
Results 1 to 4 of 4

Button to toggle worksheet protection on/off?

  1. #1
    Forum Contributor
    Join Date
    01-16-2011
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2010
    Posts
    234

    Button to toggle worksheet protection on/off?

    I have created two macros, one to lock a worksheet, and another to unlock it. I inserted two form control buttons at the bottom of the worksheet, and assigned the macros to the buttons. So now I can toggle between a locked and unlocked worksheet. But I can't tell if the sheet is locked or not.

    Now I would like to be able to see if the worksheet is locked or not. Ideally, I'd like one button that toggles the worksheet protection on and off, and the word in the button changes between "Locked" and "Unlocked". Or, I can still use two buttons, perhaps with the "Locked" word or "Unlocked" word changing color so that I can tell the locked status.

    Any help appreciated!

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Button to toggle worksheet protection on/off?

    Hi,

    I have uploaded an attachment which covers both options that you have covered above.

    In Sheet1, if the sheet is protected, the "Protect Worksheet" button is disabled and vice-versa.
    In Sheet2, the protect/unprotect function is handled with a single button.

    Note that there is code in each of the click events for the buttons, and also in the workbook open event.

    Hope this helps
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    01-16-2011
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2010
    Posts
    234

    Re: Button to toggle worksheet protection on/off?

    Thank you very much!

    I had a quick play with the Sheet 2 button. Is there a way to change the code so that the button is useable on any worksheet, despite the worksheet's name, or must the worksheet's name be in the code?

    Please find attached the worksheets that I'm working on. They're linked, and I add new daily and weekly sheets as needed by ctrl-dragging the last sheet, erasing the data, and renaming the sheet. The data is entered into the weekly worksheets, and automatically linked to the daily schedule sheets. I want to be able to toggle sheet locking with a button on the daily sheet (there's a dummy button at the bottom of the sheet), with the button displaying LOCKED or UNLOCKED, as appropriate.

    Thanks again!
    Attached Files Attached Files
    Last edited by Hambone70; 09-05-2013 at 10:34 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Button to toggle worksheet protection on/off?

    Hi,

    If you change all references to
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    then the button will work on whichever worksheet it is placed on, so you can copy the button and the code.

+ 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. Toggle Button to swap link results from another worksheet
    By mochatrpl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 10:37 PM
  2. [SOLVED] Toggle Button & getting the postion of the just pressed button
    By NugentS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2012, 11:58 AM
  3. Toggle Worksheet Protection
    By Jazzzbo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2011, 04:50 PM
  4. workbook Protection Toggle Macro
    By Just Learning in forum Excel General
    Replies: 3
    Last Post: 08-30-2005, 07:05 PM
  5. [SOLVED] Adding .xla button for Toggle Calculation Button
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2005, 09:05 AM

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