Using a Worksheet_Deactivate event, the user is not allowed to leave the active sheet if comments are not entered into certain cells. When they don't enter a required comment and try to select another sheet, it runs two Worksheet_Activate events (the sheet they try to go to and when it returns) which both display message boxes. I would really like to prevent those two Worksheet_Activate events from executing.
Code:
Private Sub Worksheet_Deactivate()
Dim r As Integer ' Row where a comment is required
Dim c As String ' Non-Production Activity where a comment is required
r = Worksheets("Non-Production").Range("CommentRequiredRow").Value
c = Worksheets("Non-Production").Range("CommentRequiredActivity").Value
If r <> 0 Then
Worksheets("Non-Production").Activate
Worksheets("Non-Production").Cells(r, 6).Select
MsgBox "Please enter a comment for " & c
Exit Sub
Else
'do nothing
End If
End Sub