I have a sheet formula of IF(Test1>0, Test1, NA())
which is designed to put a 'controlled' #N/A in the sheet if the condition is not met. Similarly, I am using IFERROR(Test2,NA())
elsewhere in the same sheet.
As the formulae for Testn are long, I would like to put them into a UDF but can't find a way to generate a 'controlled' #N/A error (one not green-flagged as an error on the sheet).
So far I have got as far as:
Function GTZero(sngInput As Single) As Variant
If sngInput > 0 Then GTZero = sngInput Else GTZero = CVErr(xlErrNA)
End Function
This is then called in the sheet as =GTZero(Test1)
. The answer looks right but Excel flags this as a true error. I don't want to just use "#N/A" text as I need to use the results in a chart and want to skip the #N/As