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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Status
Not open for further replies.

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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
Back
Top