2017-05-09 119 views
0

夥計們,動態,多層次,編號使用Excel公式

我已經成功地創建一個動態的,多層次的,只有使用Excel公式編號列表清單。這工作正常,我想我會分享結果。我唯一的問題是,如果有人想採取這一點,並試圖簡化它。我似乎無法上傳示例表(首次發佈)。

編輯我使用了一個名爲tbOOA的表,其中有2列,選擇級別和結果。要使用該公式,請複製下面不以「>開始」的代碼段的每一行,並將其複製到一個單獨(長)論壇中。

期望的結果: 成果1

產出1.1

活動1.1.1

活動1.1.2

輸出1.2

活動1.2.1

結果2

產出2.1

活動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")))))) 
+0

ChooseLevel列中可能的條目是什麼? –

+0

'結果','輸出'和'活動' –

+0

除非我在表中的第一個單元格中放置「結果」,否則我會遇到任何錯誤。我可以將其他兩個值放在第一個值以下的單元格中,但不是第一個。你能澄清嗎? –

回答

0

我能得到它歸結爲你的一半大小。

陣列式**:

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

問候

**陣列公式不以同樣的方式作爲 '標準' 式輸入。您只需按住CTRL和SHIFT鍵,而不是按下ENTER鍵,然後按ENTER鍵。如果你做得對,你會注意到Excel在公式周圍放置了大括號(儘管不要試圖自己手動插入這些)。

+0

上述答案中的輕微錯誤,即使沒有選擇「成果」,「輸出」或「活動」,我也會將其包裝在IF語句中以刪除編號。 IF([@ElevelLevel] =「」,「」, 我也加入了一個錯誤處理列,如果業務邏輯沒有被執行,它會返回一個消息,這是按預期工作的。在此之前選擇公式,我會進行調查,非常感謝您對這個問題所做的努力 –

+0

好的方面和補充,不用客氣! –