Hello Everyone
Been scouring these forums for a few days before deciding to make my own account... There's been many topics that come extremely close to what I'm looking for, yet none have been the exact same to my knowledge.
So, I'd like for the entire workbook to be Password protected upon closing it, so that every user who opens it must first input the password.
It should preferably pop up in an inputBox. If the user gets the PW right, he can modify the file to his liking.
If he gets it wrong or hits "cancel", he should still be able to look at and copy data from any cell he wants, but he cannot add anything new.
Could you guys maybe help me with that?
What I have so far:
Been scouring these forums for a few days before deciding to make my own account... There's been many topics that come extremely close to what I'm looking for, yet none have been the exact same to my knowledge.
So, I'd like for the entire workbook to be Password protected upon closing it, so that every user who opens it must first input the password.
It should preferably pop up in an inputBox. If the user gets the PW right, he can modify the file to his liking.
If he gets it wrong or hits "cancel", he should still be able to look at and copy data from any cell he wants, but he cannot add anything new.
Could you guys maybe help me with that?
What I have so far:
VBA Code:
Option Explicit
Private Sub Workbook_Open()
Dim xSheet As Worksheet
Dim xPsw As String
Dim answer As String
xPsw = "PASSWORD"
answer = InputBox("Input password if you want to unprotect" & vbLf & "all your sheets then press OK.")
If answer = xPsw Then
For Each xSheet In Worksheets
xSheet.Unprotect xPsw
Next
MsgBox "Done!"
End If
End Sub