View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gleam Gleam is offline
external usenet poster
 
Posts: 87
Default Locking worksheet based on the cell value

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
' Protect sheet with a password if sheet not
' valid for today
' Date of sheet is assumed to be in cell A1. Password is "Pass"
' Since this may be a file which is left open permanently, then
' this routine might be placed under
' This workbook / workbook / sheet change
Dim NShts As Integer, i1 As Integer
With ActiveWorkbook
NShts = .Sheets.Count
For i1 = 1 To NShts
If .Sheets(i1).Range("A1").Value < Date Then
ActiveWorkbook.Sheets(i1).Protect "Pass"
End If
Next i1
End With

End Sub


"0o0o0o0o" wrote:

I have a workbook containing 14 worksheets that are used as daily shift
report for each day of the biwekly pay period. Supervisors fill out reports
on a daily basis and managers review them every couple of days. I'd like to
limit user's ability to filling out today's report only (maybe a code that
would compare the date on the report with cell that contains =TODAY()
function, and locks the worksheet for editing if those two values don't
mach). The idea is not to allow anyone to go back and edit reports.
Any help on this would be greatly appreciated.