Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default problem with protecting sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default problem with protecting sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default problem with protecting sheet

Your code works, thanks!!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
protecting formulas without protecting sheet so grouping still wor JM Excel Discussion (Misc queries) 1 June 4th 09 06:42 AM
problem with protecting sheet bernd Excel Programming 2 October 30th 07 09:47 PM
automatic column sorting problem when protecting sheet Montana Excel Worksheet Functions 3 May 17th 07 09:55 AM
Protecting Worksheets Problem Andy Excel Programming 1 March 10th 06 08:40 PM
Protecting Sheet purplerayn Excel Worksheet Functions 1 October 21st 05 12:55 AM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"