excel 如何为具有动态序列编号的列中的动态字符串创建公式

yhived7q  于 2023-04-07  发布在  其他
关注(0)|答案(1)|浏览(166)

我如何构造公式以获得下面所需的输出。

目前,公式将给予当前输出的F列(子流程名称)的顺序编号,但问题是,当项目类型列行在中间以“新建”开始时,顺序编号应再次从序列号1开始,后面是相同的子流程名称(如图所示:-pc 3 -1,pc 5 -1),在中间,如果有“现有”与新的子流程名称,则编号将根据新的子流程名称更改为2或3(如图所示pc 4 -2,pc 4位于第一列,即请求代码)。

=IF(COUNTIF(F$2:F2,F2)=1,MAX(G$1:G1)+1,VLOOKUP(F2,F$1:G1,2,0))

上面的公式用在G列,但只会验证F列,但我需要B列也应该包括在内,以获得正确的动态序列号,有没有可能通过公式实现这一点?

pqwbnv8z

pqwbnv8z1#

如果你正在寻找一个基于单单元格公式的解决方案,这个疯狂的公式应该可以做到:

=A2&"-"&IF(COUNTIF($B$1:B2,"New")<>COUNTIF($B$1:B1,"New"),1,IFERROR(MID(INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(F2,INDIRECT("F"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&":"&CELL("address",F1)),0)),FIND("-",INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(F2,INDIRECT("F"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&":"&CELL("address",F1)),0)))+1,999),AGGREGATE(14,6,MID(INDIRECT("R"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&"C[0]:R[-1]C[0]",FALSE),FIND("-",INDIRECT("R"&AGGREGATE(15,6,ROW($B$1:$B100)/($B$1:$B100="New"),COUNTIF($B$1:B2,"New"))&"C[0]:R[-1]C[0]",FALSE))+1,999)*1,1)+1))

它覆盖了从B1到B100的列表。如果你想增加覆盖范围,在公式中相应地改变引用$B$1:$B100

评论后编辑

以下是根据注解更新的公式:

=A2&"-"&IF(COUNTIF($C$1:C2,"New")<>COUNTIF($C$1:C1,"New"),1,IFERROR(MID(INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(G2,INDIRECT("G"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&":"&CELL("address",G1)),0)),FIND("-",INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(G2,INDIRECT("G"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&":"&CELL("address",G1)),0)))+1,FIND(".",INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(G2,INDIRECT("G"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&":"&CELL("address",G1)),0)))-FIND("-",INDEX(INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE),MATCH(G2,INDIRECT("G"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&":"&CELL("address",G1)),0)))-1),AGGREGATE(14,6,MID(INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE),FIND("-",INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE))+1,FIND(".",INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE))-FIND("-",INDIRECT("R"&AGGREGATE(15,6,ROW($C$1:$C100)/($C$1:$C100="New"),COUNTIF($C$1:C2,"New"))&"C[0]:R[-1]C[0]",FALSE))-1)*1,1)+1))&"."&D2

相关问题