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

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

我正在尝试计算一列中两个非空白单元格之间的空白单元格数量。特别是两个日期和这两个日期之间的天。

我已经尝试过COUNTBLANK以及在这里和其他类似网站上找到的其他各种公式,但是我修改了它们不正确,或者它们根本不是我想要的。

My sample worksheet

enter image description here

google-sheets count google-sheets-formula array-formulas gs-vlookup
1个回答
1
投票

连续重置计数完成:

=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, 1), ), "offset 1", 0))

0

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