J
JennyJeneralGraves
I used the following code to cause a password prompt to display upon clicking
on a tab in my workbook:
Private Sub Worksheet_Activate()
Dim strPassword As String
On Error Resume Next
Me.Protect Password:="123"
Me.Columns.Hidden = True
strPassword = InputBox("Enter password to view this sheet:")
If strPassword = "" Then
Me.Previous.Select
Exit Sub
ElseIf strPassword <> "datagility" Then
MsgBox "Password Incorrect", , "Wrong password"
Me.Previous.Select
Exit Sub
Else
Me.Unprotect Password:="123"
Me.Columns.Hidden = True
End If
On Error GoTo 0
End Sub
Private Sub Worksheet_Deactivate()
On Error Resume Next
Me.Columns.Hidden = True
On Error GoTo 0
End Sub
**Problem is: when I click on the tab, the sheet is displayed in the
background behind the prompt. How can I make it so that it doesn't display at
all until the password is successfully entered?
on a tab in my workbook:
Private Sub Worksheet_Activate()
Dim strPassword As String
On Error Resume Next
Me.Protect Password:="123"
Me.Columns.Hidden = True
strPassword = InputBox("Enter password to view this sheet:")
If strPassword = "" Then
Me.Previous.Select
Exit Sub
ElseIf strPassword <> "datagility" Then
MsgBox "Password Incorrect", , "Wrong password"
Me.Previous.Select
Exit Sub
Else
Me.Unprotect Password:="123"
Me.Columns.Hidden = True
End If
On Error GoTo 0
End Sub
Private Sub Worksheet_Deactivate()
On Error Resume Next
Me.Columns.Hidden = True
On Error GoTo 0
End Sub
**Problem is: when I click on the tab, the sheet is displayed in the
background behind the prompt. How can I make it so that it doesn't display at
all until the password is successfully entered?