Microsoft Office Tutorials and References
In Depth Information
Figure 26-2: Selecting an operation from the list displays the result in cell C14.
Worksheet function data types
You may have noticed some differences in the data types used for functions and arguments so far. For instance,
in STATFUNCTION, the variable rng was declared as a Variant, while the same variable was declared as a Range
in STATFUNCTION2. Also, the former's return value was declared as a Variant, while the latter's is a Double data
type.
Data types are two-edged swords. They can be used to limit the type of data that can be passed to, or returned
from, a function, but they can also reduce the flexibility of the function. Using Variant data types maximizes flexib-
ility, but may slow execution speed a bit.
One of the possible return values of STATFUNCTION is an error in the Case Else section of the Select Case
statement. That means that the function can return a Double data type or an Error. The most restrictive data type
that can hold both an Error and a Double is a Variant (which can hold anything), so the function is typed as a Vari-
Search JabSto ::




Custom Search