Just how I would look into this.

1. Google. Example:

2. Read the first hit.
"If Sheet1.ProtectionMode = True Then
ElseIf Sheet1.Protection.AllowEditRanges = True Then

End If" is in the example to see if the sheet or ranges are protected.

3. Using that information I could alter my code to check if the sheet is protected and bail out.

Remember it's your code. You are the author so you get to find where you crashed.