Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You may want to put it in a different workbook and not share that workbook with
the macro. Then you can open the macro workbook and open the real workbook And with the real workbook open, you can use: alt-f8 and run either macro. ==== Or... Option Explicit Sub UnprotectAll() Dim wks As Worksheet Dim pwd As String pwd = InputBox(Prompt:="What's the password, Kenny?") If Trim(pwd) = "" Then Exit Sub End If For Each wks In ActiveWorkbook.Worksheets With wks If .ProtectContents = True _ Or .ProtectDrawingObjects = True _ Or .ProtectScenarios = True Then On Error Resume Next .Unprotect Password:=pwd If Err.Number < 0 Then MsgBox "Something went wrong with: " & wks.Name Err.Clear 'exit for 'stop trying??? End If On Error GoTo 0 End If End With Next wks End Sub Sub ProtectAll() Dim wks As Worksheet Dim pwd As String pwd = InputBox(Prompt:="What's the password, Kenny?") If Trim(pwd) = "" Then Exit Sub End If For Each wks In ActiveWorkbook.Worksheets With wks If .ProtectContents = True _ Or .ProtectDrawingObjects = True _ Or .ProtectScenarios = True Then 'do nothing, it's already protected Else On Error Resume Next .Protect Password:=pwd If Err.Number < 0 Then MsgBox "Something went wrong with: " & wks.Name Err.Clear 'exit for 'stop trying??? End If On Error GoTo 0 End If End With Next wks End Sub brumanchu wrote: Dave, If I wanted to share a workbook that uses this macro to protect/unprotect the sheets, could it be modified to promt me for the password? Otherwise the share-ees could run the macro and still gain access. Thanks for the help, Bruce "Dave Peterson" wrote: Option Explicit Sub UnprotectAll() dim wks as worksheet for each wks in activeworkbook.worksheets wks.unprotect password:="topsecret" next wks End Sub Sub ProtectAll() dim wks as worksheet for each wks in activeworkbook.worksheets wks.protect password:="topsecret" next wks End Sub saltnsnails wrote: I would say that I am a moderate user of Excel and I need some help with running a Macro. I have a workbook that has about 60 pages in it that several people have access to in order to edit information on each of the sheets. Each sheet has a Vlookup table that I am constantly modifying to keep items current. My problem is that I am unlocking worksheets all day long. The password is the same on all of the sheets. Is there a simple macro I can run to unlock the entire workbook rather than individually unlocking each sheet? And the same thing when I am finished and putting the file back. Can I run a macro to reassign the password protection on all of the sheets in the workbook? Thanks! -- -CRM -- Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protecting Multiple Worksheets at the same time | Excel Worksheet Functions | |||
Unprotecting worksheets | Excel Worksheet Functions | |||
Protecting multiple worksheets. | Excel Discussion (Misc queries) | |||
protecting multiple worksheets | Excel Discussion (Misc queries) | |||
PROTECTING/UNPROTECTING SHEETS | Excel Discussion (Misc queries) |