Vba for Security to Spreadsheet

Status
Not open for further replies.

neener

New Member
Joined
Aug 22, 2006
Messages
44
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
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Status
Not open for further replies.

Forum statistics

Threads
1,136,272
Messages
5,674,756
Members
419,525
Latest member
helensesc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top