在 excel 预测 sheet 中查找需求之间的间隔

Finding the interval between demands in an excel forecasting sheet

我想找到一种方法让 Excel 自动给我以下 'interval':

Month      1 2 3 4 5 6 
Demand     1 0 0 1 0 1 
'Interval' 0 0 0 3 0 2

'interval' 显示需求之间的月数。这在某种程度上可行吗?我无法在 Excel 中找到执行此操作的函数。也许 VBA 有办法?我需要这个用于 CROSTON 预测方法。

预先感谢您的时间和精力!

J。罗马人

假设 3 列是 A、B 和 C 使用:

=MATCH(1,Bn:B1,0)-1

其中 Bn 是 C 的 n

计算上一行中连续零的个数并进行调整。在 B3 中输入:

=IF(B2=0,0,COUNTIF($B:B2,"=0")-SUM($A:A3))

并复制: