ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create array function (https://www.excelbanter.com/excel-programming/315535-create-array-function.html)

Yuriy Kuznetsov

Create array function
 
How to create worksheet function that return a array into
cells ? This function return only 100 into cells (i put cell as single
or as a arry function (with ctrl+shift+enter)

Function test() As Variant
Dim a(2) As Byte
a(0) = 100
a(1) = 50
test = a
End Function

Tom Ogilvy

Create array function
 
It works for me.

Select C4:E4, go to the formula bar and enter
=Test()
then exit with Ctrl+Shift+Enter

The 3 cells must be in a single row.

If displays 100 50 0

note that A(2) produces a 3 element array, same as Dim A(0 to 2)

--
Regards,
Tom Ogilvy

"Yuriy Kuznetsov" wrote in message
...
How to create worksheet function that return a array into
cells ? This function return only 100 into cells (i put cell as single
or as a arry function (with ctrl+shift+enter)

Function test() As Variant
Dim a(2) As Byte
a(0) = 100
a(1) = 50
test = a
End Function




Yuriy Kuznetsov

Create array function
 
10x Tom:)
My mistake... I my situation I put in column not into row:(
Into column situation right usage is {=TRANSPOSE(test())}
Thanks again

Tom Ogilvy wrote:
It works for me.

Select C4:E4, go to the formula bar and enter
=Test()
then exit with Ctrl+Shift+Enter

The 3 cells must be in a single row.

If displays 100 50 0

note that A(2) produces a 3 element array, same as Dim A(0 to 2)



All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com