我想在单元格A1,A5,A9等中使用公式=SUM(B2:B3)
,但想像这样=SUM(B5:B6)
等来增加公式
尝试:
=ARRAYFORMULA(IFERROR(IF(B1:B<>"",,QUERY(IF(B1:B="",,
MMULT(N(TRANSPOSE(IF((TRANSPOSE(ROW(
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B))))))>=ROW(
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B))))))*(
{""; TRANSPOSE(TRIM(SPLIT(QUERY(REPT("♦"&ROW(INDIRECT("B1:B"&COUNTBLANK(
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B))))))), 2)&"♦",,999^99), "♦")))}=TRANSPOSE(
{""; TRANSPOSE(TRIM(SPLIT(QUERY(REPT("♦"&ROW(INDIRECT("B1:B"&COUNTBLANK(
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B))))))), 2)&"♦",,999^99), "♦")))})),
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B)))), 0))), ROW(
INDIRECT("B1:B"&MAX(IF(B1:B="",,ROW(B1:B)))))^0)), "offset 2", 0))))
我发现这也有效:
=ARRAYFORMULA(IF((MOD(ROW(A:A),3)=1)*({B2:B;""}<>""),VLOOKUP(FLOOR(ROW(A:A)-1,3),QUERY({FLOOR(ROW(A:A)-1,3),N(B:B)*(MOD(ROW(B:B)-1,3)>0)},"select Col1,SUM(Col2) group by Col1"),2,0),))