+ Reply to Thread
Results 1 to 5 of 5

Protect all with password, except 1 sheet?

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Protect all with password, except 1 sheet?

    I have the following code to protect all the sheets in my workbook with a password:
    _________________________________________________________________________________
    Sub ProtectAll()
    Dim S As Object
    Dim pWord1 As String, pWord2 As String
    pWord1 = InputBox("Please Enter the Password")
    If pWord1 = "" Then Exit Sub
    pWord2 = InputBox("Please Enter the Password")

    If pWord2 = "" Then Exit Sub
    'make certain passwords are identical
    If InStr(1, pWord2, pWord1, 0) = 0 Or _
    InStr(1, pWord1, pWord2, 0) = 0 Then
    MsgBox "You entered different passwords. No action taken"
    Exit Sub
    End If
    For Each ws In Worksheets
    ws.Protect Password:=pWord1, AllowFormattingColumns:=True
    Next
    Exit Sub

    End Sub
    _________________________________________________________________________________
    It works great, but I have 1 tiny probem: there is 1 worksheet, named "Trades" that needs to be protected, but without a password. How can I add that to the above code?
    Last edited by Lewej23; 02-28-2012 at 12:43 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    Re: Protect all with password, except 1 sheet?

    Hello LeweJ23,

    Not really knowing the makeup of your workbook, if you place the following code in your "ThisWorkbook" it will protect automatically any cells that have formulas, thus eliminating any need for individual sheet protection. Not sure if this will suffice your needs, but I thought I'd share it with you.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-24-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Protect all with password, except 1 sheet?

    This is how I protect all my sheets and then go back an unportect one. You could always reprotect that one with no password.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Protect all with password, except 1 sheet?

    Doctor Dinero's code worked perfectly!!! I added to the end the following:
    --------------------------------------------------------------------------------------------
    Sheets("Worksheet").Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
    False, AllowFormattingColumns:=True
    End Sub
    --------------------------------------------------------------------------------------------
    And it did exactly what I needed it to do! Thank-you!!!!!

  5. #5
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Protect all with password, except 1 sheet?

    Worked great! Thank-you!!!

+ 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