Consulting

Results 1 to 3 of 3

Thread: How to disable the sheets protection

  1. #1
    VBAX Regular
    Joined
    Aug 2017
    Posts
    16
    Location

    How to disable the sheets protection

    I have an excel file that has several sheets, I like todisable the protection from the sheets. I created a Vba that protects all the sheets automatically, upon closing.The problem is that some of the workersprotect an individual sheet, which interferes with the Vba, during closing.
    In advance, any help is appreciated


  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    .ProtectContents is True is the worksheet is already protected

    So maybe something like this in your Close macro would skip trying to protect a sheet that is already protected


    If Not Worksheets("ABC").ProtectContents Then
         Worksheets("ABC").Protect .......
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Aug 2017
    Posts
    16
    Location
    Paul, thanks for the suggestion.
    Originally, when I wrote this request I was in rush going toan airport so I did not explain the situation, so I apologize for theconfusion. This is the situation.
    I created a macro that protects all the sheets upon closingthe workbook, with the given password in the protect_close macro. There are times when during data entry I haveto unprotect a sheet.During this timethe staff could protect a sheet manually and use a different password, which isin the protect _close macro.
    I like to modify the Vba to ensure that if a person istrying to protect a sheet, the password would match the protect_close passwordmacro.
    Thanx in advance.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •