• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Provide password

Hi,

 I have a spreadsheet where i would like to ask for a password before i let a user see a tab

So from a command button i have the code:

Private Sub CommandButton1_Click()
Sheets("Corporate Actions").visble = True
End Sub

Before

Sheets("Corporate Actions").visble = True

Is ran, i would like a prompt for the user to give a password "XYZ" and if correct it activates the above code, if not correct, it provides a message box "Incorrect Password" and exits subs

Thanks
Seamus
0
Seamus2626
Asked:
Seamus2626
1 Solution
 
Rory ArchibaldCommented:
Something like:
Private Sub CommandButton1_Click()
If Inputbox("Please enter password") = "xyz" then
Sheets("Corporate Actions").visible = xlsheetvisible
else
msgbox "Invalid password"
end if
End Sub

Open in new window

0
 
Seamus2626Author Commented:
perfect, thanks Rory!
0
 
kgerbChief EngineerCommented:
this will do what you want I think.
Sub TestPassword()
Dim Pword As String
Pword = "XYZ"
If InputBox("Plesae enter the password", "Password Required") = Pword Then
    Sheets("Corporate Actions").Visible = True
Else
    Sheets("Corporate Actions").Visible = False
End If
End Sub

Open in new window

Kyle
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CharlWiehahnCommented:
Hi Seamus2626,

How about something like?


Private Sub CommandButton1_Click()
	strName = InputBox(Prompt:="Password please.", Title:="Password Needed", Default:="")

	If strName = "XYZ" Then
		Sheets("Corporate Actions").visble = True
	End If
End Sub

Open in new window

0
 
kgerbChief EngineerCommented:
Well, now I don't feel so bad:)  I'm not the only one who forgets to refresh:)  j/k

Kyle
0
 
Seamus2626Author Commented:
Cheers guys, thanks for the suggestions!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now