Hi, I have a spreadsheet that has a mix of locked and unlocked cells. It will be protected so that people can select, but not edit locked cells and I would like it so that after a certain date, the code locks all the cells, or makes it so that people can't select any cells in the entire workbook. So far I have this:
Private Sub Workbook_Open()
If Sheets(1).Cells(2, 2).Value <= Date Then
Dim ws As Worksheet
Dim pwd As String
pwd = "password"
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
MsgBox "This workbook is locked, please contact nobody@nowhere.com"
Else
'MsgBox "unlocked"
End If
End Sub
This works to protect all the worksheets, however I can't find a way to lock all cells
Thanks in advance for any help!
Private Sub Workbook_Open()
If Sheets(1).Cells(2, 2).Value <= Date Then
Dim ws As Worksheet
Dim pwd As String
pwd = "password"
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
MsgBox "This workbook is locked, please contact nobody@nowhere.com"
Else
'MsgBox "unlocked"
End If
End Sub
This works to protect all the worksheets, however I can't find a way to lock all cells
Thanks in advance for any help!