Returning Error from Functions

  • Thread starter Thread starter LeninVMS
  • Start date Start date
L

LeninVMS

I want to return "#N/A" and "#DIV/0" errors from a user define
function. Can someone help?

Thanks
Leni
 
Lenin,

Declare the function to return a Variant data type, and use CVErr
to create an error value. For example

Function Test() As Variant
Test = CVErr(xlErrDiv0)
' or
Test = CVErr(xlErrNA)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
cvErr(xlErrNA)

cvErr(xlErrDiv0)


? cvErr(xlErrNA)
Error 2042
? cvErr(xlErrDiv0)
Error 2007
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top