View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Password on Command Button

Private Sub CommandButton1_Click()
dim PWD as string
pwd = inputbox(Prompt:="what's the password, Kenny?")
if pwd = "yourTopSecretPaSSWordHerE" then
sheets("Sheet2").Select
else
msgbox "nope!"
end if
End Sub

But this kind of protection won't stop anyone out who really wants to see the
sheet.

Robin1979 wrote:

Hi

I have a very simple Command Button that is used for a user to change
worksheet however I would like to password protect this so that only certain
users can change into this sheet is anyone able to advise how to complete
this?

Current simple code is as follows:

Private Sub CommandButton1_Click()
Sheets("Sheet2").Select
End Sub

Thanks
Robin


--

Dave Peterson