Sub ToggleVisibilityOfDataWs() Application.EnableEvents = False Const MasterName As String = "Main" Const pw As String = "Test1" With ThisWorkbook If .ActiveSheet.Name = "Main" Then With .Worksheets("Source Data") If .Visible Then .Visible = False Else If InputBox("PLEASE ENTER PASSWORD:", "Password Security Check....") = pw Then .Visible = True Else MsgBox "INCORRECT PASSWORD - PLEASE TRY AGAIN!", vbOKOnly + vbInformation, "Feedback....." End If End If End With Else MsgBox "Can only run this macro from worksheet called " & MasterName, vbOKOnly + vbInformation, "Feedback....." End If End With Application.EnableEvents = True ActiveWindow.DisplayWorkbookTabs = True End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.