ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning Error from Functions (https://www.excelbanter.com/excel-programming/294711-returning-error-functions.html)

LeninVMS[_4_]

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

Thanks
Leni

--
Message posted from http://www.ExcelForum.com


Chip Pearson

Returning Error from Functions
 
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



"LeninVMS " wrote in
message ...
I want to return "#N/A" and "#DIV/0" errors from a user defined
function. Can someone help?

Thanks
Lenin


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Returning Error from Functions
 
cvErr(xlErrNA)

cvErr(xlErrDiv0)


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

--
Regards,
Tom Ogilvy


"LeninVMS " wrote in message
...
I want to return "#N/A" and "#DIV/0" errors from a user defined
function. Can someone help?

Thanks
Lenin


---
Message posted from http://www.ExcelForum.com/




LeninVMS[_5_]

Returning Error from Functions
 
Thanks Chip. It worked.

Regards
Leni

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com