Disbale button when worksheet protected

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top