Search code examples
excelvisual-studio-2010excel-dna

Return #N/A error from ExcelDNA


I'm pretty new to excelDNA, so I may be missing something obvious. I'm trying to return a #N/A from an excelDNA UDF. The function I'm using (via Visual Studio 2010) is below:

public static object returnError()
{
    return ExcelDna.Integration.ExcelError.ExcelErrorNA;
}

When called from an Excel worksheet, this returns a #VALUE - But I need a #N/A. I can't just return the string "#N/A", as the Excel functions like iserror() won't work on it.

Replacing the ExcelErrorNA with any other error types, for example ExcelErrorDiv0 still yields the #VALUE.

Any help would be greatly appreciated


Solution

  • Ok - it looks like you have to stop the ExcelDNA.Integration reference from copying locally to get this. Original thread I found here:

    https://groups.google.com/forum/#!topic/exceldna/MeYq0-LiGLM