XLL+ Class Library

Functions with variable return types

Our first add-in function, NORMSDIST2(), was very simple to implement. Our next example is a little more complex. The inverse function, NORMSINV2(), can fail if the input is not between 0 and 1 exclusive. In Excel, this failure is represented by the error type #NUM!.

Our next task is to use the XLL+ Function Wizard to generate a function that returns either a number or an error, depending on whether it is successful.

Select a source file

Make sure that Developer Studio is open and that Tutorial1 is the active project. Open or activate the file Tutorial1.cpp.

Invoke the Function Wizard

In Developer Studio, using the XLL+ Toolbar, click on the New Function tool. (In Visual Studio .NET or Visual Studio 2005, use the New XLL+ Function item on the Tools menu.) This will start the Function Wizard.

Enter function details

In the Add New Function dialog, fill in the name, category and description of the function as follows:

Name:NORMSINV2
Category:Statistical
Description:Returns the inverse of the standard normal cumulative distribution. The distribution has a mean of zero and a standard deviation of one.

After you click on OK, the main Function Wizard dialog will appear, so that you can enter the other details of the new add-in function.

Next: Returning CXlOper >>