?
.
Hi,
I just created a UDF in VB.Net say
Function GetTextOnly(TextOnly as object) as object
' =GetTextOnly("AnyString")
If TextOnly.GetType.Equals(Gettype(String)) then Return "This is a String"
' =GetTextOnly(A1) and A1 set to AnyString
Dim RefValue as object = Ctype(TextOnly,excel.range).value
If RefValue.GetType.Equals(Gettype(String)) then Return "This is a range
containing a String"
End Function
I've done some testing on that function in Excel A2 ie
Function return as expected
A2
Function Return
=GetTextOnly("AnyString") This is a String
=GetTextOnly(A1) and A1 set to AnyString This is a range containing a
String
Function return as not expected
=GetTextOnly(A1) and A1 set to nothing #Value
=GetTextOnly(A1) and A1 set to 123 0
In fact, I want my UDF to return #N/A (as a real Excel error) ie not a
string "#N/A" but the correct Excel constant #N/A (-2146826246)
Thanks for your help
I just created a UDF in VB.Net say
Function GetTextOnly(TextOnly as object) as object
' =GetTextOnly("AnyString")
If TextOnly.GetType.Equals(Gettype(String)) then Return "This is a String"
' =GetTextOnly(A1) and A1 set to AnyString
Dim RefValue as object = Ctype(TextOnly,excel.range).value
If RefValue.GetType.Equals(Gettype(String)) then Return "This is a range
containing a String"
End Function
I've done some testing on that function in Excel A2 ie
Function return as expected
A2
Function Return
=GetTextOnly("AnyString") This is a String
=GetTextOnly(A1) and A1 set to AnyString This is a range containing a
String
Function return as not expected
=GetTextOnly(A1) and A1 set to nothing #Value
=GetTextOnly(A1) and A1 set to 123 0
In fact, I want my UDF to return #N/A (as a real Excel error) ie not a
string "#N/A" but the correct Excel constant #N/A (-2146826246)
Thanks for your help