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
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)))),"")
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)
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)
G Column currently the same as F
Explaining for formulas:
"Tipas" is a named range reffering to current row H column
"ps.nr", "s.nr", "dg.nr", "d.nr" are named ranges for current row number
"prev.col.range" is a named range getting range from header row until current row
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.
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.
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? 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.
CodePudding user response:
Put this formula in 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:
=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.