+ Reply to Thread
Results 1 to 2 of 2

Amend the Code

  1. #1
    Registered User
    Join Date
    07-18-2005
    Posts
    1

    Amend the Code

    Dear Experts,

    please amend the following code to turn off the Workbook & Worksheet protections while the following code runs & turn on protection again at the end.
    Workbook password "xyz" worksheet password "xyz"

    ------------------------------------------------------------------------------------------
    Sub Button1_Click()
    Dim Pass As String

    Pass = InputBoxDK("Please enter your password", "Hide Sheets")

    If Pass = "123" Then
    If Worksheets("a").Visible = True Then
    Sheets(Array("a", "b", "c", "d")).Visible = False
    Else
    Sheets("a").Visible = True
    Sheets("b").Visible = True
    Sheets("c").Visible = True
    Sheets("d").Visible = True
    End If
    Else
    MsgBox "Incorrect password", vbCritical, "Invalid Password"
    End If

    End Sub
    --------------------------------------------------------------------------------------------------


    Thanks for your efforts.

    S h a n

  2. #2
    Registered User
    Join Date
    08-20-2003
    Location
    Luton, England
    Posts
    63
    Like this :-
    Worksheets("A").Unprotect password:="xx"
    Workbooks("Book1.xls").Unprotect password:="xx"



    Don't forget to re-protect afterwards.
    Regards
    BrianB
    Most problems are caused by starting from the wrong place.
    Use a cup of coffee to speed up all Windows processes.
    It's easy until you know how.
    -----------------------------------------

+ 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