使用 Excel 公式的动态、多级、编号列表
Dynamic, multi-level, numbered list using Excel formula
各位,
我仅使用 excel 公式就成功地创建了一个动态的、多级的、编号的列表。这工作正常,我想我会分享结果。我唯一的问题是是否有人想接受它并尝试简化它。我似乎无法上传示例 sheet(第一次发布)。
编辑 我正在使用一个名为 tbOOA 的 table,有 2 列,选择级别和结果。要使用该公式,请复制下面编码部分中不以 > 开头的每一行,并将其复制到一个(长)论坛中。
想要的结果:
结果 1
输出 1.1
Activity 1.1.1
Activity 1.1.2
输出 1.2
Activity 1.2.1
结果 2
输出 2.1
Activity 2.1.1 等等等等
>The formula explained:
>First choose if it is an Outcome, Output or Activity. If blank, then nothing
=IF([@[Choose Level]]="","",
>If it is an Outcome, put the word "Outcome" into column C
IF([@[Choose Level]]="Outcome", "Outcome " &
>and concatenate it with a count of the number of "Outcome" already chosen, limited from the header of the table, until this row
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]], [@[Choose Level]]),
>Else, if "Output" is chosen, put the word "Output"
IF([@[Choose Level]]="Output", "Output "&
>and concatenate it with the number of "Outcome" from the table header to this line
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]],"Outcome")
>and concatentate it with a dot and then
&"."&
>(This was the difficult part of the formula)
>count how many instances of "Output" there are between the last (most recent) instance of "Outcome" and the current row
COUNTIF(INDIRECT(ADDRESS(SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Outcome"))),COLUMN([@[Choose Level]]))&":"&ADDRESS(ROW([@[Choose Level]]),COLUMN(([@[Choose Level]]))),TRUE),"Output"),
>Else, it must be an "Activity", so put "Activity"
"Activity " &
>and concatenate with the number of "Outcome" from table header to this row, and dot
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]],"Outcome")&"."&
>and count how many instances of "Output" between the last "Outcome" and this line
COUNTIF(INDIRECT(ADDRESS(SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Outcome"))),COLUMN([@[Choose Level]]))&":"&ADDRESS(ROW([@[Choose Level]]),COLUMN(([@[Choose Level]]))),TRUE),"Output")&"."&
>and finally, count how many instances of "Activity" since the last "Output"
ROW([@[Choose Level]])-SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Output"))))))
我可以把它缩小到你的一半左右。
数组公式**:
=CHOOSE(MIN(ROWS(INDEX([ChooseLevel],1):[@ChooseLevel]),4),"Outcome1","Output1.1","Activity1.1.1",[@ChooseLevel]&COUNTIF(INDEX([ChooseLevel],1):[@ChooseLevel],"Outcome")&IF([@ChooseLevel]="Outcome","",SUBSTITUTE("."&COUNTIF([@ChooseLevel]:INDEX([ChooseLevel],MATCH(1,0/(INDEX([ChooseLevel],1):[@ChooseLevel]="Outcome"))),"Output")&"."&COUNTIF([@ChooseLevel]:INDEX([ChooseLevel],MATCH(1,0/(INDEX([ChooseLevel],1):[@ChooseLevel]="Output"))),"Activity"),".0","")))
此致
**数组公式的输入方式与 'standard' 公式不同。您不是只按 ENTER,而是先按住 CTRL 和 SHIFT,然后再按 ENTER。如果操作正确,您会注意到 Excel 将大括号 {} 放在公式周围(尽管不要尝试自己手动插入)。
各位,
我仅使用 excel 公式就成功地创建了一个动态的、多级的、编号的列表。这工作正常,我想我会分享结果。我唯一的问题是是否有人想接受它并尝试简化它。我似乎无法上传示例 sheet(第一次发布)。
编辑 我正在使用一个名为 tbOOA 的 table,有 2 列,选择级别和结果。要使用该公式,请复制下面编码部分中不以 > 开头的每一行,并将其复制到一个(长)论坛中。
想要的结果: 结果 1
输出 1.1
Activity 1.1.1
Activity 1.1.2
输出 1.2
Activity 1.2.1
结果 2
输出 2.1
Activity 2.1.1 等等等等
>The formula explained:
>First choose if it is an Outcome, Output or Activity. If blank, then nothing
=IF([@[Choose Level]]="","",
>If it is an Outcome, put the word "Outcome" into column C
IF([@[Choose Level]]="Outcome", "Outcome " &
>and concatenate it with a count of the number of "Outcome" already chosen, limited from the header of the table, until this row
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]], [@[Choose Level]]),
>Else, if "Output" is chosen, put the word "Output"
IF([@[Choose Level]]="Output", "Output "&
>and concatenate it with the number of "Outcome" from the table header to this line
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]],"Outcome")
>and concatentate it with a dot and then
&"."&
>(This was the difficult part of the formula)
>count how many instances of "Output" there are between the last (most recent) instance of "Outcome" and the current row
COUNTIF(INDIRECT(ADDRESS(SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Outcome"))),COLUMN([@[Choose Level]]))&":"&ADDRESS(ROW([@[Choose Level]]),COLUMN(([@[Choose Level]]))),TRUE),"Output"),
>Else, it must be an "Activity", so put "Activity"
"Activity " &
>and concatenate with the number of "Outcome" from table header to this row, and dot
COUNTIF(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]],"Outcome")&"."&
>and count how many instances of "Output" between the last "Outcome" and this line
COUNTIF(INDIRECT(ADDRESS(SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Outcome"))),COLUMN([@[Choose Level]]))&":"&ADDRESS(ROW([@[Choose Level]]),COLUMN(([@[Choose Level]]))),TRUE),"Output")&"."&
>and finally, count how many instances of "Activity" since the last "Output"
ROW([@[Choose Level]])-SUMPRODUCT(MAX(ROW(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]])*(tbOOA[[#Headers],[Choose Level]]:[@[Choose Level]]="Output"))))))
我可以把它缩小到你的一半左右。
数组公式**:
=CHOOSE(MIN(ROWS(INDEX([ChooseLevel],1):[@ChooseLevel]),4),"Outcome1","Output1.1","Activity1.1.1",[@ChooseLevel]&COUNTIF(INDEX([ChooseLevel],1):[@ChooseLevel],"Outcome")&IF([@ChooseLevel]="Outcome","",SUBSTITUTE("."&COUNTIF([@ChooseLevel]:INDEX([ChooseLevel],MATCH(1,0/(INDEX([ChooseLevel],1):[@ChooseLevel]="Outcome"))),"Output")&"."&COUNTIF([@ChooseLevel]:INDEX([ChooseLevel],MATCH(1,0/(INDEX([ChooseLevel],1):[@ChooseLevel]="Output"))),"Activity"),".0","")))
此致
**数组公式的输入方式与 'standard' 公式不同。您不是只按 ENTER,而是先按住 CTRL 和 SHIFT,然后再按 ENTER。如果操作正确,您会注意到 Excel 将大括号 {} 放在公式周围(尽管不要尝试自己手动插入)。