How to get a function in VBA to return NA?

VBADummy

New Member
Joined
Nov 23, 2005
Messages
2
I searched this in the boards and could not find an answer. If it has been covered, I am sorry. I am new to the board.

How do you get a function that you write in VBA to return an excel NA()? I have tried almost everything and can not get it to work.

Thanks
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Welcome to the Board.

Example:

Code:
Function MyFunc(arg) As Variant
    If IsNumeric(arg) Then
        MyFunc = arg * 2
    Else
        MyFunc = CVErr(xlErrNA)
    End If
End Function

For other possibilites check out the XlCVError constants in the Object Browser.
 

Watch MrExcel Video

Forum statistics

Threads
1,119,123
Messages
5,576,228
Members
412,709
Latest member
AD04
Top