result = DetectDividebyZero(1, 0) Function DetectDividebyZero(a, b) On Error GoTo [Error] DetectDividebyZero= (a/ b) Exit Function [Error] If Err = 11 Then '11 is the error number raised when divide by zero occurs Notice "Divide by Zero Detected!" End If End Function