Need Unprotect/Protect for Excel Macro

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
 
K

Ken Wright

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top