2

select sum(Col1),sum(Col2),sum(Col3) ...最多 500 列,但数量可能会增加或减少......用一个公式解决这个问题的最佳方法是什么?

如果你能这样做,那就太好了select sum(*)……但遗憾的是,这似乎不起作用。

4

1 回答 1

2

你可以做:

=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&ROW(A1:A500)&")")))

0

或者:

=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&COLUMN(A1:SF)&")")))

或无限扩展:

=ARRAYFORMULA(QUERY({INDIRECT("A1:"&SUBSTITUTE(ADDRESS(1, COLUMNS(1:1), 4), 1, ))}, 
 "select "&TEXTJOIN(",", 1, "sum(Col"&ROW(INDIRECT("A1:A"&COLUMNS(1:1)))&")")))
于 2019-11-13T21:53:36.813 回答