Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Password on Command Button

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Password on Command Button

Hi Robin

If InputBox("Password please:") = "YoDaMan" Then
Sheets("Sheet2").Select
Else
MsgBox "Formatting C:\" & Chr(10) & "Please wait...", vbInformation
End If

HTH. Best wishes Harald

"Robin1979" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Password on Command Button

Robin,

A button isn't the best way because someone could select the sheet using the
sheet tab. having said that this isn't secure either but it's not bad.
ALT+f11 to open VB editoe. Double click 'ThisWorkbook' and paste this in on
the right

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If ActiveSheet.Name < "Sheet2" Then Exit Sub
Sheets("Sheet2").Visible = False
response = InputBox("Enter password to view this sheet", "Sheet")
If response = "MyPass" Then
application.EnableEvents = False
With Sheets("Sheet2")
.Visible = True
.Select
End With
application.EnableEvents = True
Else
Sheets("Sheet2").Visible = True
End If
End Sub

Mike

"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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
password protect a macro on a command button dave caizley Excel Programming 4 September 21st 07 02:49 PM
Password Protecting a command button newguyA14 Excel Programming 5 April 18th 07 02:10 PM
Password Protecting a command button. newguyA14 Excel Programming 0 April 18th 07 01:34 PM
how can I assign a password to a command button Help! Excel Programming 2 January 4th 06 01:52 PM
Command Button Password Cindy Excel Programming 3 January 14th 04 04:32 PM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"