View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default password protect a macro on a command button

Something like the following may suffice:

Sub ButtonClick()
If StrComp(ThisWorkbook.Worksheets("Sheet1").Range("A 1").Value, "yes",
vbTextCompare) < 0 Then
' cell A1 is not 'yes'.
Exit Sub
End If
''''''''''''''''''''''''''
' rest of your code here
''''''''''''''''''''''''''
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"dave caizley" wrote in message
...
Hi

There is a Command Button on my worksheet that I only want selected users
to
be able to use.

Is there some simple code I can put at the start of the Macro so that
unless
"Yes" is typed in to cell A1, the Macro doesnt activate when the button is
pressed

Many thanks