How to protect a sheet if ...

  • Thread starter Thread starter Alf
  • Start date Start date
A

Alf

Hi,

I have an XL file with a data to be entered by a user using one sheet per
date.
I also have a Results summary sheet where I use this sort of function,
=SUM(Monday 1st : Friday 5th!B3).

I would like to implement "Conditional protection" where a data sheet can
no longer be modified after a certain date. Example, if today is Tuesday
2nd, then the "Monday 1st"
sheet can no longer be modified.

An ideas ???

TIA

N.L.
 
You need VBA.

Put thios code in the ThisWorkbook code module

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target A
Range)

Application.EnableEvents = False
On Error GoTo proc_exit
If CDate(Sh.Name) < Date Then
If Sh.ProtectContents <> True Then
Target.Value = ""
Sh.Protect
MsgBox "Changes not allowed to this sheet"
End If
End If
proc_exit:
Application.EnableEvents = True
End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top