Automatic Sheet Protection - possible??

RobbieR

New Member
Joined
Feb 3, 2004
Messages
11
Is there any way that I can set it up on my sheet so that if the value of cell A1 is greater than Cell A2 then the sheet protection enables. The eventual aim of this excercise is that A1 will be "=TODAY()" and A2 will be a pre-set date, therefore if todays date exceeds the preset date, the sheet protection enables and no-one can add anything further to that sheet. Can this be done at all?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
insert this on the Thisworkbook module

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()
<SPAN style="color:#00007F">Dim</SPAN> sht <SPAN style="color:#00007F">As</SPAN> Worksheet
<SPAN style="color:#00007F">If</SPAN> Worksheets("sheet1").Range("a1").Value > Worksheets("sheet1").Range("b1").Value <SPAN style="color:#00007F">Then</SPAN>
    ThisWorkbook.Protect password:="workbookpassowrd"
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> sht <SPAN style="color:#00007F">In</SPAN> ThisWorkbook.Worksheets
        sht.Protect password = "worksheetpassword"
    <SPAN style="color:#00007F">Next</SPAN> sht
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

RobbieR

New Member
Joined
Feb 3, 2004
Messages
11
Thats great. I have that working. Now... can I refine it further so that if they try to change anything (after it is protected) instead of the standard message saying "The cell or chart you are trying to change is protected blah blah blah". You can insert a user defined message? :rolleyes:
 

Mudface

MrExcel MVP
Joined
Feb 18, 2002
Messages
3,339
I don't think you can have a user-defined message to replace the protection warning unfortunately.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,160
Messages
5,768,527
Members
425,480
Latest member
br400821

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top