Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hello,
When selecting a sheet1 the sheet is protected. Depending on the value (xx) in a cell on sheet2, I want sheet 1 to be unprotected or stay protected. I made a reference to the cell on sheet2: status I created the following code but doesn't work. Private Sub Worksheet_Activate () If Range(status) = "xx" Then Activesheet.Unprotect Password:= "pass" Else: Activesheet.Protect Password:= "pass" End If End Sub How do I solve this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try it like this:
Private Sub Worksheet_Activate() If ThisWorkbook.Sheets("Sheet2").Range("Status") = "xx" Then ActiveSheet.Unprotect Password:="pass" Else ActiveSheet.Protect Password:="pass" End If End Sub -- Hope that helps. Vergel Adriano "bernd" wrote: hello, When selecting a sheet1 the sheet is protected. Depending on the value (xx) in a cell on sheet2, I want sheet 1 to be unprotected or stay protected. I made a reference to the cell on sheet2: status I created the following code but doesn't work. Private Sub Worksheet_Activate () If Range(status) = "xx" Then Activesheet.Unprotect Password:= "pass" Else: Activesheet.Protect Password:= "pass" End If End Sub How do I solve this? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your code works, thanks!!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
protecting formulas without protecting sheet so grouping still wor | Excel Discussion (Misc queries) | |||
problem with protecting sheet | Excel Programming | |||
automatic column sorting problem when protecting sheet | Excel Worksheet Functions | |||
Protecting Worksheets Problem | Excel Programming | |||
Protecting Sheet | Excel Worksheet Functions |