ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect ALL cells If Q (https://www.excelbanter.com/excel-programming/302141-protect-all-cells-if-q.html)

John[_78_]

Protect ALL cells If Q
 
I want to protect all cells in a workbook if the Contents of cell B1 7. My
thinking is that if the value of Cell B1 7 then the worksheet should not
be worked on, kind of a security feature

Is there any such code I should use?

Thanks



Tom Ogilvy

Protect ALL cells If Q
 
How does B1 get to be 7. Manual entry? Formula? Macro?

--
Regards,
Tom Ogilvy

"John" wrote in message
...
I want to protect all cells in a workbook if the Contents of cell B1 7.

My
thinking is that if the value of Cell B1 7 then the worksheet should not
be worked on, kind of a security feature

Is there any such code I should use?

Thanks





John[_78_]

Protect ALL cells If Q
 
Hi Tom

It will be a formula based on =(NOW())-A1, so if the user tries to work on
the form after 7 days, they wouldn't be allowed to. A1 will change based on
external data every week


"Tom Ogilvy" wrote in message
...
How does B1 get to be 7. Manual entry? Formula? Macro?

--
Regards,
Tom Ogilvy

"John" wrote in message
...
I want to protect all cells in a workbook if the Contents of cell B1

7.
My
thinking is that if the value of Cell B1 7 then the worksheet should

not
be worked on, kind of a security feature

Is there any such code I should use?

Thanks







Tom Ogilvy

Protect ALL cells If Q
 
right click on the sheet tab and select view code.

Paste in code like this:

Private Sub Worksheet_Calculate()
If Range("B1").Value 7 Then
If ActiveSheet.ProtectContents = False Then
Me.Cells.Locked = True
Me.Protect
End If
End If
End Sub


--
Regards,
Tom Ogilvy

"John" wrote in message
...
Hi Tom

It will be a formula based on =(NOW())-A1, so if the user tries to work on
the form after 7 days, they wouldn't be allowed to. A1 will change based

on
external data every week


"Tom Ogilvy" wrote in message
...
How does B1 get to be 7. Manual entry? Formula? Macro?

--
Regards,
Tom Ogilvy

"John" wrote in message
...
I want to protect all cells in a workbook if the Contents of cell B1

7.
My
thinking is that if the value of Cell B1 7 then the worksheet should

not
be worked on, kind of a security feature

Is there any such code I should use?

Thanks









John[_78_]

Protect ALL cells If Q
 
Super Tom Thanks for that


"Tom Ogilvy" wrote in message
...
right click on the sheet tab and select view code.

Paste in code like this:

Private Sub Worksheet_Calculate()
If Range("B1").Value 7 Then
If ActiveSheet.ProtectContents = False Then
Me.Cells.Locked = True
Me.Protect
End If
End If
End Sub


--
Regards,
Tom Ogilvy

"John" wrote in message
...
Hi Tom

It will be a formula based on =(NOW())-A1, so if the user tries to work

on
the form after 7 days, they wouldn't be allowed to. A1 will change based

on
external data every week


"Tom Ogilvy" wrote in message
...
How does B1 get to be 7. Manual entry? Formula? Macro?

--
Regards,
Tom Ogilvy

"John" wrote in message
...
I want to protect all cells in a workbook if the Contents of cell B1


7.
My
thinking is that if the value of Cell B1 7 then the worksheet

should
not
be worked on, kind of a security feature

Is there any such code I should use?

Thanks












All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com