首页 > 解决方案 > How can I create a list of numbers that is like the following?

问题描述

I want to create a list of number like this in Excel, in separate cells:

(column B);
1
1
2
1
2
3
1
2
3
4
.
.
.
.

If you can't see each number is sequences from one up to the number your on.

标签: excelvba

解决方案


仅使用公式,不使用 VBA:

在 B 列中:

1 | 1
2 | 1
3 | =IF(B2-MAX(B$1:B1)<1,B2+1,1)

然后填写该公式

如果您只想要一个独立的公式(不引用其他单元格),您可以使用这个更强大的公式在 term n = ROW() 处评估三角形序列:

=IFERROR(ROW() - COMBIN(INT((1+SQRT(8*ROW()))/2), 2),1)

(IFERROR 部分只处理第一项,它试图评估 COMBIN(1,2) )


推荐阅读