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 Disbale button when worksheet protected

I'd just have the code in the commandbutton check to see if the worksheet is
protected:

Option Explicit
Private Sub CommandButton1_Click()
If Me.ProtectContents _
Or Me.ProtectDrawingObjects _
Or Me.ProtectScenarios Then
Beep
'or
MsgBox "it's protected"
Exit Sub
End If

'your real code
End Sub

If you're protecting the worksheet in code, you could disable the commandbutton
when you protect/unprotect the worksheet.



Sarah (OGI) wrote:

Is there any way of disabling a button on a worksheet when the worksheet is
protected, i.e. I do not want people to click the button to refresh the data
if the sheet is protected? (the button is from the Control Toolbox toolbar)

Any ideas?


--

Dave Peterson