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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

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.
 

Forum statistics

Threads
1,186,160
Messages
5,956,266
Members
438,244
Latest member
gaelen

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