Pinaceous
Well-known Member
- Joined
- Jun 11, 2014
- Messages
- 1,113
- Office Version
- 365
- Platform
- Windows
Good Day Everyone!
I have a workbook with multiple worksheets.
Upon a worksheet, I have a private sub that runs the following code and locks the sheet based upon an expire date.
It works well but I notice a flaw upon the sheet; only after it is executed.
When you switch from one worksheet tab to the next worksheet tab; the code seems to become undone.
Where the user can access any cell upon the "locked" sheet and even type in a cell.
Do you know of a way to prevent the cursor from accessing a cell upon the "locked" sheet?
Or is there a way to prevent the user to selecting the other worksheets tabs without hiding the sheet tabs?
Or do you have any other suggestions?
Thank you,
Pinaceous
I have a workbook with multiple worksheets.
Upon a worksheet, I have a private sub that runs the following code and locks the sheet based upon an expire date.
VBA Code:
Sub Macro26()
'
'Time Lock Macro
'Worksheets(2).Activate
With ThisWorkbook.Worksheets(2)
Select Case True
Case Not IsEmpty(Sheet1.Range("D3").Value)
If Date > (.Range("D3") + 9) Then
'1 = 1 whole day after Sheet1.D3
'2 = 2 whole days after Sheet1.D3
Call YOUSUBLOCK_1
MsgBox "Your sheet has expired and has been protected!", vbInformation
End If
Exit Sub
Case IsEmpty(Sheet1.Range("D3").Value)
Exit Sub
End Select
End With
End Sub
It works well but I notice a flaw upon the sheet; only after it is executed.
When you switch from one worksheet tab to the next worksheet tab; the code seems to become undone.
Where the user can access any cell upon the "locked" sheet and even type in a cell.
Do you know of a way to prevent the cursor from accessing a cell upon the "locked" sheet?
Or is there a way to prevent the user to selecting the other worksheets tabs without hiding the sheet tabs?
Or do you have any other suggestions?
Thank you,
Pinaceous