电子表格从另一个工作表动态选择行,工作表名称也在查询中

问题描述 投票:0回答:1

我有这个疑问

    =ARRAYFORMULA(QUERY({
IFERROR({INDIRECT(A1&"!C2:E"), IF(INDIRECT(A1&"!C2:C")<>"", A1, "")}, {"","","",""}); 
IFERROR({INDIRECT(A2&"!C2:E"), IF(INDIRECT(A2&"!C2:C")<>"", A2, "")}, {"","","",""}); 
IFERROR({INDIRECT(A3&"!C2:E"), IF(INDIRECT(A3&"!C2:C")<>"", A3, "")}, {"","","",""}); 
IFERROR({INDIRECT(A4&"!C2:E"), IF(INDIRECT(A4&"!C2:C")<>"", A4, "")}, {"","","",""}); 
IFERROR({INDIRECT(A5&"!C2:E"), IF(INDIRECT(A5&"!C2:C")<>"", A5, "")}, {"","","",""}); 
IFERROR({INDIRECT(A6&"!C2:E"), IF(INDIRECT(A6&"!C2:C")<>"", A6, "")}, {"","","",""}); 
IFERROR({INDIRECT(A7&"!C2:E"), IF(INDIRECT(A7&"!C2:C")<>"", A7, "")}, {"","","",""}); 
IFERROR({INDIRECT(A8&"!C2:E"), IF(INDIRECT(A8&"!C2:C")<>"", A8, "")}, {"","","",""}); 
IFERROR({INDIRECT(A9&"!C2:E"), IF(INDIRECT(A9&"!C2:C")<>"", A9, "")}, {"","","",""}); 
IFERROR({INDIRECT(A10&"!C2:E"), IF(INDIRECT(A10&"!C2:C")<>"", A10, "")}, {"","","",""}); 
IFERROR({INDIRECT(A11&"!C2:E"), IF(INDIRECT(A11&"!C2:C")<>"", A11, "")}, {"","","",""}); 
IFERROR({INDIRECT(A12&"!C2:E"), IF(INDIRECT(A12&"!C2:C")<>"", A12, "")}, {"","","",""})
}, "select Col4, Col1, Col2 where Col3 contains 'AutoService'", 0)) 

返回以下错误在 ARRAY_LITERAL 中,数组文字缺少一行或多行的值。

这是因为我还没有创建最后 3 张

enter image description here

enter image description here

基本上我想从 12 个带有月份名称的不同工作表中选择 3 列。我还想包括行所在月份的名称。

google-sheets google-sheets-formula
1个回答
0
投票

这是一种替代方法,您可以相应地进行调整:

=let(Σ,tocol(,1), reduce(Σ,tocol(A1:A12,1),lambda(a,c,vstack(if(iserr(+a),Σ,a),let(Λ,filter(iferror(indirect(c&"!C2:D"),iferror(now()/0)),regexmatch(indirect(c&"!E2:E"),"(?i)autoservice")),if(iserror(Λ),Σ,hstack(wrapcols(c,rows(Λ),c),Λ)))))))

picture

重要:创建新选项卡(例如 4 月)时,

indirect()
默认情况下不会自动选择它。要立即提示更新,请在工作表中的任意位置进行某种编辑/更改;例如,它可以像勾选复选框或在单元格中输入 1 一样简单......

© www.soinside.com 2019 - 2024. All rights reserved.