Excel:password protected sheets
Closed
she27
Posts
1
Registration date
Wednesday 25 September 2013
Status
Member
Last seen
28 September 2013
-
28 Sep 2013 à 01:12
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 30 Sep 2013 à 11:55
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 30 Sep 2013 à 11:55
Related:
- Excel:password protected sheets
- Excel mod apk for pc - Download - Spreadsheets
- Vat calculation excel - Guide
- Excel online macros - Guide
- Kernel for excel repair - Download - Backup and recovery
- Menu déroulant excel - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
30 Sep 2013 à 11:55
30 Sep 2013 à 11:55
Hi she27,
Keep in mind that macro's can always be disabled.
You can change both passwords which are the 3rd and 4th codeline.
Here is the code:
Trowa
Keep in mind that macro's can always be disabled.
You can change both passwords which are the 3rd and 4th codeline.
Here is the code:
Private Sub Workbook_Open()Best regards,
Dim UserPass, AdminPass As String, sh As Worksheet, x As Integer
UserPass = "Username"
AdminPass = "Admin"
TryAgain:
MyPass = Application.InputBox("Please enter your password:")
If MyPass = False Then
MsgBox "Workbook will now be closed."
ActiveWorkbook.Close
End If
If MyPass = UserPass Then
x = 0
Do
x = x + 1
Sheets(x).Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Loop Until x = 4
Do
x = x + 1
Sheets(x).Visible = False
Loop Until x = 7
ElseIf MyPass = AdminPass Then
For Each sh In Worksheets
ActiveSheet.Unprotect
Next sh
x = 4
Do
x = x + 1
Sheets(x).Visible = True
Loop Until x = 7
Else
y = MsgBox("The entered password is incorrect.", vbOKCancel)
If y = vbCancel Then
MsgBox "Workbook will now be closed."
ActiveWorkbook.Close
End If
GoTo TryAgain
End If
End Sub
Trowa