计算一列中非空白单元格之间的连续空白单元格

时间:2019-10-06 05:28:13

标签: google-sheets count google-sheets-formula array-formulas gs-vlookup

我正在尝试计算一列中两个非空白单元格之间的空白单元格数量。具体来说就是两个日期和两个日期之间的日期。

我已经尝试过COUNTBLANK以及在这里和其他类似网站上找到的各种其他公式,但是我修改的方式有误,或者根本不是我想要的。< / p>

My sample worksheet

enter image description here

2 个答案:

答案 0 :(得分:2)

连续重置计数的完成方式如下:

=ARRAYFORMULA(IF(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)="", MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>=TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)=""))-HLOOKUP(0, MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)="")), MATCH(VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)<>G1:G), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)<>G1:G), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), 0), 0), ))

0


更新:

=ARRAYFORMULA(QUERY(IF(iF(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)="", MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>=TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)=""))-HLOOKUP(0, MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)="")), MATCH(VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)<>G1:G), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)<>G1:G), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), 0), 0), )=1, ARRAY_CONSTRAIN(SORT({IF(INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)="", MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>=TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)=""))-HLOOKUP(0, MMULT(N(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))>TRANSPOSE(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)))), N(INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)="")), MATCH(VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)<>{"×"; INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)}), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), VLOOKUP(ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), IF(N(INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)<>{"×"; INDEX(SORT({
 INDIRECT("G2:G"&COUNTA(F2:F)+1), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0),, 1)}), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1)), ), 1, 1), 0), 0), ), ROW(
 INDIRECT("G2:G"&COUNTA(F2:F)+1))}, 2, 0), 999^99, 1), ), "offset 1", 0))

0

答案 1 :(得分:1)

除了player0提供的解决方案外,我还创建了一张额外的工作表并输入到单元格I2中

=ArrayFormula(if(len(G2:G), iferror(vlookup(G2:G, query({if(row(G2:G) <= max(if(not(isblank(F2:F)), row(G2:G))),vlookup(row(G2:G),filter({row(G2:G),G2:G},len(G2:G)),2),), --isblank(G2:G)}, "Select Col1, Sum(Col2) where Col2 > 0 group by Col1"), 2, 0)),))

看看是否可行?