Programming and Application(编程与应用)


Content(目录)




Linux


MySQL
Office















 
PCNow 30-Day Free Trial, Remote PC Access
 
Logo_234x60

Use array in a costomized worksheet function


Use array in a costomized worksheet function

Zhanshan Dong

We know there are a lot of worksheet functions that use an array as an argument. How can we use an array as an argument in our costomized worksheet functions? I'd like to address this question step by step.
1) The function declaration. In the function declaration part, you should declare an array parameter as an object. For example,
Function Test(Range1 as Object)
2) To access the elements in an input array. You can use traditional For-Next loop to access the elements in an array as we do for arrays declared in the function by DIM command.
3) To get the dimension size of an input array. Use UBOUND function to achieve the purpose. For example,
nSize = UBound(Range1(), 1)
This command will get the size of the first dimension of the input array. It is worthy to mention that the input array in the UBound function must be written like array name followed a pair of parentheses.
To see an example of using an input array, please refer to an article called "Enhanced Chi-Square Test Function in Excel".
©董占山Zhanshan Dong

Post comments(留言)

Name(名字):

Comment(内容):


由Google提供

SunfineData Products|U's Bargain Network|Contact Me(与我联系)
© 1998-, 董占山, 版权所有, 欢迎转载文章链接。
转载文章和软件请注明出处(http://articles.sunfinedata.com/)。