kiddbran10
New Member
- Joined
- May 14, 2018
- Messages
- 2
Hey everyone,
I've been scrolling around throughout the forums trying to find a piece of code that will help me with my situation, but have been unable to get any suggestions to work with my workbook. That may be due to it not working with my workbook, or because I can't figure out how to properly code in excel.
To explain my situation: I have a daily log that needs to be filled out on a daily basis, the workbook has 31 sheets (one for each day). On each sheet, I put that sheets date (Example: On May 1, the cell will say 2018-05-01, on the sheet for May 2 it will say 2018-05-02) into cell T1.
The following code is what I've been trying to run
Where "1st" is equal to the first sheet in the workbook named "1st", and where cell "20, 1" is equal to cell T1, and where date +1 is supposed to make the sheet lock the following day.
Bonus question, can I have the sheet lock at a certain date and time, as our day's closing time is 7am rather than midnight.
Thanks in advance for all your help!
I've been scrolling around throughout the forums trying to find a piece of code that will help me with my situation, but have been unable to get any suggestions to work with my workbook. That may be due to it not working with my workbook, or because I can't figure out how to properly code in excel.
To explain my situation: I have a daily log that needs to be filled out on a daily basis, the workbook has 31 sheets (one for each day). On each sheet, I put that sheets date (Example: On May 1, the cell will say 2018-05-01, on the sheet for May 2 it will say 2018-05-02) into cell T1.
The following code is what I've been trying to run
Code:
Private Sub Workbook_Open() If Sheets("1st").Cells(20, 1).Value >= Date And Sheets("1st").Cells(20, 1).Value <= Date + 1 Then
ActiveWorkbook.Protect Password:="password"
MsgBox "This workbook is locked, please contact xxx@xxx.com"
Else
'MsgBox "unlocked"
End If
End Sub
Where "1st" is equal to the first sheet in the workbook named "1st", and where cell "20, 1" is equal to cell T1, and where date +1 is supposed to make the sheet lock the following day.
Bonus question, can I have the sheet lock at a certain date and time, as our day's closing time is 7am rather than midnight.
Thanks in advance for all your help!