Hello all,
I am very new to this, so please be patient.
I have a very large spreadsheet in Excel 2010, and the creator would like every worksheet to be opened after entering a password. I've tried the protection available on the tab of the worksheet, but the creator does not even want people to view the data. So...in effect, the worksheet cannot be viewed in the spreadsheet until a password is entered.
To make it worse for me, I am not used to Excel 2010. I do have a VB script that I believe will work, but cannot get it to work in the workbook. I can view it, edit it, but not invoke it!!!
The script is:
Public PvSh As String
Public Pwd As String
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Pwd = "" Then
If Sh.Name = "Sheet2" Then
Num = ActiveWindow.Index
Windows(Num).Visible = False
If Application.InputBox("Enter Password", "Password") <> "airplane" Then
MsgBox "Incorrect Password", vbCritical, "Error"
Application.EnableEvents = False
Sheets(PvSh).Select
Application.EnableEvents = True
Else
Pwd = "airplane"
End If
Windows(Num).Visible = True
End If
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
PvSh = Sh.Name
End Sub
End Sub
so...again to summarize:
1. User opens spreadsheet.
2. Spreadsheet has four tabs.
3. User selects to view second tab.
4. Before able to view, user is prompted for a password.
5. If user enters correct password (airline), then allowed to view worksheet, else error message "incorrect password".
6. This password check happens each time the sheet is opened.
I would so appreciate some help!!!
Patricia
I am very new to this, so please be patient.
I have a very large spreadsheet in Excel 2010, and the creator would like every worksheet to be opened after entering a password. I've tried the protection available on the tab of the worksheet, but the creator does not even want people to view the data. So...in effect, the worksheet cannot be viewed in the spreadsheet until a password is entered.
To make it worse for me, I am not used to Excel 2010. I do have a VB script that I believe will work, but cannot get it to work in the workbook. I can view it, edit it, but not invoke it!!!
The script is:
Public PvSh As String
Public Pwd As String
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Pwd = "" Then
If Sh.Name = "Sheet2" Then
Num = ActiveWindow.Index
Windows(Num).Visible = False
If Application.InputBox("Enter Password", "Password") <> "airplane" Then
MsgBox "Incorrect Password", vbCritical, "Error"
Application.EnableEvents = False
Sheets(PvSh).Select
Application.EnableEvents = True
Else
Pwd = "airplane"
End If
Windows(Num).Visible = True
End If
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
PvSh = Sh.Name
End Sub
End Sub
so...again to summarize:
1. User opens spreadsheet.
2. Spreadsheet has four tabs.
3. User selects to view second tab.
4. Before able to view, user is prompted for a password.
5. If user enters correct password (airline), then allowed to view worksheet, else error message "incorrect password".
6. This password check happens each time the sheet is opened.
I would so appreciate some help!!!
Patricia