[英]Excel: How to repeat multiple values based on a cell value X times, including a repeated pattern
I'm new to this forum so apologies if I haven't posted this question correctly.我是这个论坛的新手,如果我没有正确发布这个问题,我深表歉意。 Would really appreciate any help if possible.如果可能的话,真的很感激任何帮助。 Thanks in advance.提前致谢。 Data input in columns A - E and desired outcome in columns G - K (picture attached). A - E 列中的数据输入和 G - K 列中的预期结果(附图片)。
Codes I have tired to edit my self but can't quite get it to work:我已经厌倦了编辑自己的代码,但不能完全让它工作:
'https://www.extendoffice.com/documents/excel/4054-excel-duplicate-rows-based-on-cell-value.html#a1 'https://www.extendoffice.com/documents/excel/4054-excel-duplicate-rows-based-on-cell-value.html#a1
Excel How To Repeat multiple values based on a Cell Value X Times Excel如何根据单元格值重复多个值X次
Going through the steps logically:逻辑地完成这些步骤:
I am trying to create a document control system where the document names are identified before the project starts.我正在尝试创建一个文档控制系统,其中在项目开始之前识别文档名称。 The "Unique Document Number" includes a formula to give me the unique number. “唯一文件编号”包含一个公式,可以为我提供唯一编号。 The reason for the gaps is I can conditional format the cells into colours to identify headings and sub-headings.出现间隙的原因是我可以有条件地将单元格格式化为颜色以识别标题和子标题。
There could be 12 No. folders A - L and within them 6 sub-folders 001 - 006, making the list very long.可能有 12 个编号文件夹 A - L,其中有 6 个子文件夹 001 - 006,使列表很长。 Having recognised the pattern I feel this could be automated, but struggling.认识到这种模式后,我觉得这可以自动化,但很挣扎。
Regards问候
In an effort to solve this without VBA You need a couple of helper columns:为了在没有 VBA 的情况下解决这个问题,您需要几个辅助列:
P repetitions
P2 = E2
P3 = =IF(P2>1,P2-1,INDIRECT("E" & Q3))
Q row
Q2 = 2
Q3 = =IF(P2>1,Q2,Q2+1)
R First Sub Number Helper
R3 = 1
R4 = =IF(MOD(P4,5)>0,R3,R3+1)
Then to your table:然后到你的桌子:
G1 = =H2&IF(I2<>"","-"&I2,"")&IF(J2<>"","-"&J2,"")&IF(K2<>"","-"&K2,"")
H1 = A2
H2 = =IF(P2>1,H2,INDIRECT("A" & Q3))
I3 = R3
I4 = =IF(P4>P3,"",R4)
J2 = =IF(OR(I2="",MOD(P2,5)=0),"",XLOOKUP(H2,A:A,C:C))
K1 = =IFS(OR(J2="",MOD(P2,5)>3),"",MOD(P2,5)=3,1,MOD(P2,5)=2,2,MOD(P2,5)=1,3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.