I have written what I consider to be a very simple function to test a cell for data validation but clearly I am missing something. The function returns true when it should return false and, after being run once, I receive a Function not defined error.

I have rewritten it many different ways; here is the current version:
Public Function HasValidation(TheCell As Range) As Boolean

HasValidation = False
On Error GoTo NO_VALIDATION
valtype = TheCell.Validation.Type
If valtype >= 0 Then
    HasValidation = True
End If
On Error GoTo 0
Exit Function

NO_VALIDATION:
Exit Function

End Function
The function is stored in my PERSONAL.xlsb workbook and I am testing the function through the Immediate window of the VBE. I have tried referring to ActiveCell as well as a range with the same results. It works once but doesn't necessarily return the correct value and then I receive the "Sub or Function not defined" error on subsequent attempts.

No clue why this isn't working.