+ Reply to Thread
Results 1 to 3 of 3

Multiple protections

  1. #1
    Registered User
    Join Date
    10-11-2005
    Posts
    2

    Multiple protections

    Hi , is it possible to lock and unlock with protection passwords (all using same password) multiple sheets, in a workbook by using just one command or do they have to be all done individually?

    Guy B

  2. #2
    Valued Forum Contributor
    Join Date
    06-30-2005
    Location
    Verwood, Dorset, England
    MS-Off Ver
    Excel 2000
    Posts
    479
    Quote Originally Posted by GuyB
    Hi , is it possible to lock and unlock with protection passwords (all using same password) multiple sheets, in a workbook by using just one command or do they have to be all done individually?

    Guy B
    Hi GuyB

    You will need a macro to do this, see details below.

    If you want this just for 1 workbook put the macro into the Visual Basic Editor for that sheet, if you want it available for all workbooks you will need to put it into the visual basic editor for Personal.xls

    Public Sub Unprotect_All()
    Dim wks As Worksheet
    Dim vPword As Variant
    On Error Resume Next
    For Each wks In ActiveWorkbook.Worksheets
    With wks
    .Unprotect vPword
    Do While .ProtectContents
    vPword = Application.InputBox( _
    prompt:="Enter password for " & .Name, _
    Title:="Unprotect sheets", _
    Default:="", _
    Type:=2)
    If vPword = False Then Exit Sub 'user cancelled
    .Unprotect vPword
    Loop
    End With
    Next
    End Sub

    Public Sub Protect_All()
    Dim wks As Worksheet
    Dim vPword As Variant
    vPword = Application.InputBox( _
    prompt:="Enter Password: ", _
    Title:="Protect sheets", _
    Default:="", _
    Type:=2)
    If vPword = False Then Exit Sub 'user cancelled
    For Each wks In ActiveWorkbook.Worksheets
    wks.Protect vPword
    Next
    End Sub
    Paul

  3. #3
    Registered User
    Join Date
    10-11-2005
    Posts
    2
    Hey Paul, thnak you for your assistance.
    I am creating reports for a school and hope that this may save me time.
    Cheers
    Guy B

+ 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