View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
papou[_9_] papou[_9_] is offline
external usenet poster
 
Posts: 52
Default Macro for worksheet protection

Hi Floos
How abour a custom function?
Public Function unprotectSh(Sh As String)
z = "YourPassword"
unprotectSh = Sheets(Sh).Unprotect(z)
End Function

Public Function protectSh(Sh As String)
z = "YourPassword"
protectSh = Sheets(Sh).Protect(z)
End Function

And use functions in your module, ie:
Sub Macro1()
unprotectSh("Sheet1")
'Do some stuff...
protectSh("Sheet1")
End Sub

HTH
Cordially
Pascal

"Floss" a écrit dans le message de
...
Hi,

Need help with macro code to run a passworded worksheet 'Protect' and one

to 'Unprotect' it.

Thank you.
Floss