Need Unprotect/Protect for Excel Macro

  • Thread starter Thread starter Wade
  • Start date Start date
W

Wade

Hello there,
I need the code to put into a macro to go in and
unprotect a sheet (just long enough for me to insert some
data)...then re-protect the sheet before saving. This
way....the user cannot destroy the data or formula in teh
protected sheet.

How do I do this? Is there a global command or do I have
to imput my password when I ask it to follow me recording
the macro.

Please help! Anyone!! Thanks!!

Wade
 
Previous post of J E McGimpseys will give you the syntax

Sub Toggleprotect2()
Const PWORD As String = "ken"
Dim wkSht As Worksheet

For Each sh In ActiveWorkbook.Worksheets
If sh.ProtectContents = False Then
sh.Protect PWORD
Else
sh.Unprotect PWORD
End If
Next sh
End Sub
 
Back
Top