简体   繁体   English

在 EXCEL 中创建动态分层编号。 在满足某些条件后重置计数

[英]Creating a dynamic hierarchical numbering in EXCEL. Reset the count after certain criteria is met

I'm trying to create a gantt chart sheet with dynamic hierarchical numbering.我正在尝试使用动态分层编号创建甘特图。 The set up of the chart is like so:图表的设置是这样的:

The set up and what is currently achieved设置和目前取得的成果

Formulas used:使用的公式:

B column =D13&"."&E13&"."&F13&"."&G13 B栏=D13&"."&E13&"."&F13&"."&G13

D column =IF(tipas<>"", IF(ROW(ps.nr)=ROW($D$9)+4,1,IF(tipas="R","",IF(tipas="PS",MAX(prev.col.range)+1, MAX(prev.col.range)))),"") D列=IF(tipas<>"", IF(ROW(ps.nr)=ROW($D$9)+4,1,IF(tipas="R","",IF(tipas="PS",MAX(prev.col.range)+1, MAX(prev.col.range)))),"")

E column =IF(tipas<>"", IF(OR(tipas="PS", tipas="R"),"",IF(ROW(s.nr)=ROW($E$9)+4,1,IF(tipas="S",MAX(prev.col.range)+1, MAX(prev.col.range)))),-1) E列=IF(tipas<>"", IF(OR(tipas="PS", tipas="R"),"",IF(ROW(s.nr)=ROW($E$9)+4,1,IF(tipas="S",MAX(prev.col.range)+1, MAX(prev.col.range)))),-1)

F column =IF(tipas<>"", IF(OR(tipas="PS",tipas="S",tipas="R"),"",IF(ROW(d.nr)=ROW($F$9)+4,1,IF(OR(tipas="D",tipas="DG",tipas="M"),MAX(prev.col.range)+1, MAX(prev.col.range)))),-1) F列=IF(tipas<>"", IF(OR(tipas="PS",tipas="S",tipas="R"),"",IF(ROW(d.nr)=ROW($F$9)+4,1,IF(OR(tipas="D",tipas="DG",tipas="M"),MAX(prev.col.range)+1, MAX(prev.col.range)))),-1)

G Column currently the same as F G 列当前与 F 相同

Explaining for formulas:解释公式:

"Tipas" is a named range reffering to current row H column “Tipas”是一个命名范围,引用当前行 H 列

"ps.nr", "s.nr", "dg.nr", "d.nr" are named ranges for current row number “ps.nr”、“s.nr”、“dg.nr”、“d.nr”是当前行号的命名范围

"prev.col.range" is a named range getting range from header row until current row “prev.col.range”是一个命名范围,从标题行到当前行

As far as the chart types ("tipas" Column H) are set up in perfect order PS then S and D then it works kind of perfectly.至于图表类型(“tipas”H 列)以完美的顺序设置 PS 然后是 S 和 D 然后它工作得非常完美。

The problem starts when I try to achieve the dynamical part.当我尝试实现动态部分时,问题就开始了。 For example if I change type to S anywhere in the middle and there are tasks (type D) before it the counting set's off and the numbering is lost.例如,如果我在中间的任何地方将类型更改为 S,并且在它之前有任务(类型 D),则计数集关闭并且编号丢失。

Illustration of what I'm trying to achieve我正在努力实现的目标的插图

The main question would be:主要问题是:

How could I reset the numbering of F column if the value of column H is PS or S and stop the addition to the number if the value is DG?如果 H 列的值为 PS 或 S,我如何重置 F 列的编号,如果值为 DG,如何停止添加到数字? While column G should start the count only if the value of column H is DG and stop and reset if it's anything else than DG.而 G 列仅在 H 列的值为 DG 时才开始计数,如果不是 DG 则停止并重置。

Put this formula in F13:把这个公式放在 F13 中:

=IF(H13<>"",IF(OR(H13="PS",H13="S",H13="R"),"",IF(ROW(H13)=ROW($F$9)+4,1,IF(G13="",IF(OR(H13="D",H13="DG",H13="M"),MAX(INDIRECT("F"&AGGREGATE(14,6,1/(($H$13:H13="PS")+($H$13:H13="S"))*ROW($H$13:H13),1)&":"&CELL("address",F12)))+1,MAX(INDIRECT("F"&AGGREGATE(14,6,1/(($H$13:H13="PS")+($H$13:H13="S"))*ROW($H$13:H13),1)&":"&CELL("address",F12)))),F12))),-1)

This one in G13: G13中的这个:

=IF(AND(OR(H12="DG",G12<>""),OR(H13="D",H13="M")),IF(H13="R","",IF(G12="",1,G12+1)),"")

They should returns you what you were expecting (as far as the data you provided can assure that).他们应该返回您所期望的(只要您提供的数据可以保证)。 Test and send feedback.测试并发送反馈。 Questions and/or reports of errors/misfunctions are welcome and will most likely be addressed.欢迎提出错误/功能错误的问题和/或报告,并且很可能会得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM