开发者

Reverse a 1d array output from a function (or get the last value), without VBA?

开发者 https://www.devze.com 2023-04-12 09:28 出处:网络
Suppose I have a UDF MyFunc() which is too costly to call more than once, MyFunc() returns an array.By default, if applied to a single cell then the first value in the arr开发者_StackOverflow社区ay is

Suppose I have a UDF MyFunc() which is too costly to call more than once, MyFunc() returns an array. By default, if applied to a single cell then the first value in the arr开发者_StackOverflow社区ay is used. I want the last value of the array.

So, is it possible to:

  • (a) reverse the array so that the last value is used, or

  • (b) just grab the last value directly?


You can use INDEX to return a certain position

If you know the position you want you could use

=INDEX(Myfunct(),2)

for the second position etc

For the last position of unknown size

=INDEX(Myfunct(),COUNTA(Myfunct()))

second last

=INDEX(Myfunct(),COUNTA(Myfunct())-1)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号