The information in this article applies to:
SUMMARY
In Microsoft Excel 98 Macintosh Edition, there are two different methods of
returning multiple values from a custom function: one for returning a
variable-sized array and one for returning a fixed-size array.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp Method to Return a Variable-Size Result ArrayThis method returns an array of values based on an argument range. The size of the resulting array fluctuates depending on the number of elements in the argument array. For example, assume that you want to create a function that multiplies each value in a range by 100. The following custom function accepts an array (a range of values) as its argument:
To use the custom function, enter the following data in cells A1:A4:
Select the range B1:B4 and enter the following formula as an array:
=Multiply_Range(A1:A4)NOTE: The above formula must be entered as an array formula. To enter a formula as an array formula, press COMMAND+ENTER. The result will be:
Method to Return Array Result of a Fixed SizeThis method for returning multiple values from a custom function assumes that you have a fixed number of elements in the resulting array.The following custom function accepts a starting time and an ending time and returns the number of hours, minutes, and seconds between them in a 3- row by 1-column array.
To use this custom function, enter a starting time and a finish time in
two cells (for example, A1 and A2 below).
Then, highlight three cells in a column (for example, A3 through A5) and
enter the following as an array formula:
=Elapsed_Time(A1,A2)NOTE: The above formula must be entered as an array formula. To enter a formula as an array formula, press COMMAND+ENTER. The result will appear as follows:
If you prefer to enter the function horizontally into a range of cells
instead of vertically, change the Elapsed_Time line to read:
Elapsed_Time = Array(hours, minutes, seconds) REFERENCES
For more information about Arrays, from the Visual Basic Editor,
click the Office Assistant, type array, click Search, and then click to
view "Using Arrays."
Q176476 OFF: Office Assistant Not Answering Visual Basic QuestionsFor additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: Q163435 VBA: Programming Resources for Visual Basic for Applications Additional query words: XL98
Keywords : kbdta xlvbahowto xlvbainfo |
Last Reviewed: February 1, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |