Thread: msgbox on error
View Single Post
  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

It might just be easier to check the protection status of the worksheet first:

Option Explicit
Sub testme()

Dim wks As Worksheet

Set wks = ActiveSheet

With wks
If .ProtectContents _
Or .ProtectDrawingObjects _
Or .ProtectScenarios Then
MsgBox "Can't run on a protected sheet"
Exit Sub
End If
End With

End Sub

Ciara wrote:

i have protected a worksheet - if i click a command button I get

Run - time error '1004
Application defined or object defined error
(with options to debug etc....)

which is good because i don't want the command buttons to work while the
sheet is protected

however, i want my own message to come up with no options to debug/end/help.

any ideas on code for this?


--

Dave Peterson