Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to password protect the worksheet when the userform is closed and
unprotect it when the userform is open. Can anyone help me??? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() enyaw wrote: I need to password protect the worksheet when the userform is closed and unprotect it when the userform is open. Can anyone help me??? How about.... Call ProtectSheet(False, "Sheet1") frmUserForm.Show 1 ... do whatever provessing the form requires ... Call ProtectSheet(True, "Sheet1") Private Sub ProtectSheet(bProtect As Boolean, sSheet As String) If bProtect Then Worksheets(sSheet).Protect Password:="<your password", AllowFiltering:=True Else Worksheets(sSheet).Unprotect ("<your password") End If End Sub I use a string variable to hold the password, and ProtectSheet because I can use it for different worksheets, but you can just as easily use just the code within the IF statement if you wish. HTH |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() enyaw wrote: I need to password protect the worksheet when the userform is closed and unprotect it when the userform is open. Can anyone help me??? How about.... Call ProtectSheet(False, "Sheet1") frmUserForm.Show 1 ... do whatever provessing the form requires ... Call ProtectSheet(True, "Sheet1") Private Sub ProtectSheet(bProtect As Boolean, sSheet As String) If bProtect Then Worksheets(sSheet).Protect Password:="<your password", AllowFiltering:=True Else Worksheets(sSheet).Unprotect ("<your password") End If End Sub I use a string variable to hold the password, and ProtectSheet because I can use it for different worksheets, but you can just as easily use just the code within the IF statement if you wish. HTH |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect Workbook Vs Protect Sheet | New Users to Excel | |||
Can I protect columns w/in a "List" using Protect Sheet? | Excel Discussion (Misc queries) | |||
Lock and protect cells without protect the sheet | Excel Programming | |||
Protect the sheet | Excel Programming | |||
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet | Excel Programming |