XLL+ Class Library (7.0)

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.

Invoke the Function Wizard

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

Use the New XLL+ Function item on the Tools menu to start the Function Wizard.

Enter function details

In the Add New Function dialog, fill in the name, NORMSINV2, and click OK.

In the XLL+ Function Wizard, fill in the category and description of the function as follows:

Return type: CXlOper
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.

Next: Returning CXlOper >>