Excel:password protected sheets
Closed
she27
Posts
1
Registration date
Wednesday September 25, 2013
Status
Member
Last seen
September 28, 2013
-
Sep 28, 2013 at 01:12 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Sep 30, 2013 at 11:55 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Sep 30, 2013 at 11:55 AM
Related:
- Excel:password protected sheets
- Excel marksheet - Guide
- Excel free download - Download - Spreadsheets
- Number to words in excel - Guide
- Kernel for excel - Download - Backup and recovery
- Excel date format dd.mm.yyyy - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
552
Sep 30, 2013 at 11:55 AM
Sep 30, 2013 at 11:55 AM
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