3

I have a custom function in Excel 2007. It returns array of doubles.

Dim ResultArray(10) As Double

If I use it with Ctrl-Shift-Enter I get 10 results in a row.

I want to access a particular resut within the result array.

Say second result. I'd expect something like =myFn(a,b,c)(2) but it doesnt work....

Is it possible?

2
  • Is it (2) or [2] .. array syntax is different in any language. Also I think you should try varA = myFn(a,b,c) and then do varA(2) (or varA[2]). Finally, you could write a second function with an extra parameter as index of the double you actually want. Commented Nov 14, 2010 at 16:14
  • Actually, myFn(a,b,c)(2) is perfectly valid VBA syntax, but as your accepted answer states, the Excel worksheet function to use is INDEX. Commented Nov 14, 2010 at 19:44

1 Answer 1

8

Use the Index function to get certain element of Array.

=Index(myFn(a,b,c); 2)
Sign up to request clarification or add additional context in comments.

2 Comments

or maybe comma instead of semicolon? semicolon works in openoffice
semicolon is used as separator instead of comma in various locales, especially in Slavic ones

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.