Hello everyone:
Sub Code()
Dim pwd As String
pwd = InputBox("Enter Password")
If pwd <> "bacon" Then MsgBox ("wrong Password")
End Sub
I entered the above vba code to create a enter password box for a sheet
in my work.As soon as I entered this portion and tried to run it,a box
appeared on top of a regular spreadsheet asking me for the password,I entered the password which was bacon and it took me back to the vba sheet
where my code is.What else must I enter as code so when I go to open my spreadsheet then and only then it asks me for a password in a box,and when you enter the correct password it leaves you on the spreadsheet and not take you to the vba sheet?And if you enter the wrong password it exits you out and closes my spreadsheet work?
Can somebody please help me?
Neen
Sub Code()
Dim pwd As String
pwd = InputBox("Enter Password")
If pwd <> "bacon" Then MsgBox ("wrong Password")
End Sub
I entered the above vba code to create a enter password box for a sheet
in my work.As soon as I entered this portion and tried to run it,a box
appeared on top of a regular spreadsheet asking me for the password,I entered the password which was bacon and it took me back to the vba sheet
where my code is.What else must I enter as code so when I go to open my spreadsheet then and only then it asks me for a password in a box,and when you enter the correct password it leaves you on the spreadsheet and not take you to the vba sheet?And if you enter the wrong password it exits you out and closes my spreadsheet work?
Can somebody please help me?
Neen