简体   繁体   English

从Excel中的INDEX函数返回数组?

[英]Return array from INDEX function in Excel?

I'm trying to use INDEX in array format in Excel but I'm running into problems. 我正在尝试在Excel中以数组格式使用INDEX,但是遇到了问题。

From this question: Return array from INDEX function? 从这个问题: 从INDEX函数返回数组? , it seems that "INDEX (like VLOOKUP) doesn't return an array of values (except in some convoluted circumstances)" ,似乎“ INDEX(如VLOOKUP)不返回值数组(在某些复杂情况下除外)”

So I'm wondering what alternatives there are. 所以我想知道有什么替代方案。

I'm trying to do this: 我正在尝试这样做:

=qlTimeSeries( ,
               INDEX({39618,39619,39638,39639},{2,3,4}),
               INDEX({18,19,38,39},{2,3,4})
               )

and Index is not returning an array. 并且Index不返回数组。

Any alternative idea how to get the result I am trying to get with INDEX({39618,39619,39638,39639},{2,3,4})? 还有其他想法如何获得我尝试使用INDEX({39618,39619,39638,39639},{2,3,4})获得的结果吗? ie from {39618,39619,39638,39639} get {39619,39638,39639} back? 即从{39618,39619,39638,39639}获得{39619,39638,39639}回来吗?

NOTE: Instead of INDEX({39618,39619,39638,39639},{2,3,4}) my spreadsheet in fact uses a dynamic array of dates and the objective is to drop the first element of the array {39618,39619,39638,39639} which is why I am using INDEX. 注意:我的电子表格实际上使用动态日期数组来代替INDEX({39618,39619,39638,39639},{2,3,4}),目的是删除数组{39618,39619 ,39638,39639},这就是为什么我使用INDEX的原因。

EDIT: Looking for a solution that avoids using VBA 编辑:寻找避免使用VBA的解决方案

Try this array formula: 试试这个数组公式:

= INDEX({39618,39619,39638,39639},N(IF({1},{2,3,4})))

This will return what you desire: {39619,39638,39639} . 这将返回您想要的内容: {39619,39638,39639}

Note this is an array formula, so you must press Ctrl + Shift + Enter on the keyboard after typing this formula instead of just pressing Enter . 请注意,这是一个数组公式,因此您必须在键入此公式后按键盘上的Ctrl + Shift + Enter ,而不是仅按Enter

(Also note this works with dynamic ranges, not just hard-coded arrays.) (还要注意,这适用于动态范围,而不仅仅是硬编码的数组。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM