generating a #VALUE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
One way might be to trying adding a number and a letter..

Function Test()
Test = 1 + "a"
End Function
 
Have your function return a variant

Function myFunc(arg1 as ...) as Variant
'some code here
myFunc = CVErr(xlErrValue)
end function
 
forcing an error in excel will give the results. This worked for me

Function test(target As Range)

test.Value2 = "Error 2015"
End Function
 

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