ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   generating a #VALUE (https://www.excelbanter.com/excel-programming/398313-generating-value.html)

Smallweed

generating a #VALUE
 
I have a UDF which, if it can't find what it's looking for, I want to return
and show #VALUE in the cell. Any ideas how do I do this? Thanks.

Chip Pearson

generating a #VALUE
 
Use the CVErr function to create an Error type Variant and return that as
the result of the function.

Function Whatever() As Variant
If Something Then
Whatever = CVErr(xlErrValue)
End If
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Smallweed" wrote in message
...
I have a UDF which, if it can't find what it's looking for, I want to
return
and show #VALUE in the cell. Any ideas how do I do this? Thanks.



Vergel Adriano

generating a #VALUE
 
One way might be to trying adding a number and a letter..

Function Test()
Test = 1 + "a"
End Function



--
Hope that helps.

Vergel Adriano


"Smallweed" wrote:

I have a UDF which, if it can't find what it's looking for, I want to return
and show #VALUE in the cell. Any ideas how do I do this? Thanks.


Dave Peterson

generating a #VALUE
 
Have your function return a variant

Function myFunc(arg1 as ...) as Variant
'some code here
myFunc = CVErr(xlErrValue)
end function



Smallweed wrote:

I have a UDF which, if it can't find what it's looking for, I want to return
and show #VALUE in the cell. Any ideas how do I do this? Thanks.


--

Dave Peterson

joel

generating a #VALUE
 
forcing an error in excel will give the results. This worked for me

Function test(target As Range)

test.Value2 = "Error 2015"
End Function

"Smallweed" wrote:

I have a UDF which, if it can't find what it's looking for, I want to return
and show #VALUE in the cell. Any ideas how do I do this? Thanks.



All times are GMT +1. The time now is 12:02 AM.

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