您可以使用以下任一公式:
Using TEXTSPLIT()
& TEXTJOIN()
with REPT()
=TEXTSPLIT(TEXTJOIN("-",,REPT(A2:A3&"|",B2:B3)),"-","|",1)
Or,
使用友好名称创建自定义公式LAMBDA()
• 单元格中使用的公式C2
=REPEAT.NTIMES(A2:A3,B2:B3)
卓越LAMBDA()
函数为我们提供了一种创建可以在整个工作簿中重用的自定义函数的方法,而无需使用VBA
,有一个friendly name
.
中使用的公式为姓名经理如下所示,带有测试语法
=LAMBDA(values,num_repeat,
XLOOKUP(SEQUENCE(SUM(num_repeat)),
VSTACK(1,SCAN(1,num_repeat,LAMBDA(a,b,a+b))),
VSTACK(values,""),,-1))(A2:A3,B2:B3)
Copy the above formula, not including the testing parameters at the end, press CTRL+F3, this opens the Name Manager, click New.
In the New Name dialog, enter the name REPEAT.NTIMES, leave the scope set to workbook, and paste the formula you copied into the "Refers to" input area, press OK.
现在既然LAMBDA()
公式有一个名称,它可以像任何其他函数一样在工作簿中使用。
最后,为了获得运行号码,我们可以使用COUNTIF()
功能,
• 单元格中使用的公式D2
=COUNTIF(C$2:C2,C2)