Excel中的趋势持续时间

时间:2018-04-13 15:25:30

标签: excel

假设我想告诉Excel:

if A2<x count following cells (A2, A3, ...) until <x is not satisfied anymore and print the number of consecutive cells in which the condition is satisfied; else print 0.

(其中x是用户定义的常量)。

我该如何编码呢?

1 个答案:

答案 0 :(得分:0)

x 放在 A1 中,然后在另一个单元格中输入:

=MATCH(TRUE,INDEX(A2:A9999>=A1,0),)-1

enter image description here

在此示例中, x 10 并且有6个以 A2 开头的连续单元格,其值低于 10 。因此,当遇到第8行时计数停止,因为 A8 中的值不小于 A1 中的值。

如果所有值低于限制,要强制 0 ,请使用:

=IFERROR(MATCH(TRUE,INDEX(A2:A9999>=A1,0),)-1,0)