Hello,
I have placed the following code in ThisWorkbook to hide all but a warning sheet if the user does not have Macros Enabled. Two questions:
(1) If macros are enabled, instead of Unhiding All sheets, how may I just want to unhide certain sheets (i.e.; "Submission Form", etc.)? Please provide example.
(2) I would like to include a subroutine that runs on Workbook_Open that does the following:
(a) on a specific date: show a msgbox saying "Expired", and prompt the user to enter a password.
(b) If the password is invalid, hide all sheets and save and close the workbook.
Any suggestions? Thanks!
-------------------------------------
Private Const dsWarningSheet As String = "Warning" 'This is the Macro warning worksheet
Private Sub Workbook_Beforesave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
For Each ds In ActiveWorkbook.Sheets
If LCase(dsWarningSheet) = LCase(ds.Name) Then
ds.Visible = True
Else: ds.Visible = xlVeryHidden = 2
End If
Next
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal ds As Object, ByVal Target As Excel.Range)
If LCase(ds.Name) = LCase(dsWarningSheet) Then
For Each ds In ActiveWorkbook.Sheets
ds.Visible = True
Next
ActiveSheet.Visible = xlVeryHidden
End If
End Sub
Private Sub workbook_open()
Sheets(dsWarningSheet).Select
For Each ds In ActiveWorkbook.Sheets
ds.Visible = True
Next
ActiveSheet.Visible = xlVeryHidden
End Sub
Bookmarks