Big Chemical Encyclopedia

Chemical substances, components, reactions, process design ...

Articles Figures Tables About

A Function That Takes an Indefinite Number of Arguments

A CUSTOM FUNCTION THAT TAKES AN INDEFINITE NUMBER OF ARGUMENTS [Pg.303]

Many of Excel s worksheet functions can accept an indefinite number of arguments. The SUM function is an example of such a function its syntax is =SUM(number1,number2.). To create a custom function with an indefinite number of arguments, use the Param Array keyword. An argument declared with ParamArray is an array of Variants, and each element of the array can itself be an array. [Pg.303]

Since LINEST requires that there be the same number of values for each independent variable, we first check to make sure that each range in the array of arguments has the same number of rows. An interesting point although we specified Option Base 1, the ParamArray keyword produces an array whose lower array index is zero. Thus we must loop from 0 to UBound(rng). Note that UBound(rng) is the number of elements in the array, while [Pg.303]

If an array element is not the correct size, we need to return an error value. Use the CVErr keyword to return a worksheet error value that Excel can handle appropriately. The error values are listed in Appendix D. [Pg.304]

After checking all the elements in the array, we assemble them into the final array of dimensions XSize rows by YMax columns, and return the array to the worksheet. [Pg.304]




SEARCH



Argument

Indefinite number of arguments

Number function

Takes

© 2024 chempedia.info