[英]VBA: Copy range of data rows x times
I need to copy and paste the same information (in order), 1000 times into the same column.我需要将相同的信息(按顺序)复制并粘贴到同一列中 1000 次。 The data will run from 1990-2019, separated into quarters...数据将从 1990 年到 2019 年运行,分为几个季度......
1990 FY1990 FQ11990 31-Jan-90 1
1990 FY1990 FQ21990 31-Jan-90 2
1990 FY1990 FQ31990 31-Jan-90 3
1990 FY1990 FQ41990 31-Jan-90 4
1990 FY1990 FQ11990 31-Jan-90 1
1990 FY1990 FQ21990 31-Jan-90 2
etc
etc
Is there a code I can write to automate this?有没有我可以编写的代码来自动执行此操作?
I believe you are mistaking, I believe the expected result is more like:我相信你错了,我相信预期的结果更像是:
1990 FY1990 FQ11990 31-Jan-90 1
1990 FY1990 FQ21990 31-Jan-90 2
1990 FY1990 FQ31990 31-Jan-90 3
1990 FY1990 FQ41990 31-Jan-90 4
1991 FY1991 FQ11991 31-Jan-91 1
1991 FY1991 FQ21991 31-Jan-91 2
etc
etc
In order to do this, you should realise that your expected output looks like:为此,您应该意识到您的预期输出如下所示:
aaaa FYaaaa FQbaaaa 31-Jan-aa b
where:在哪里:
aaaa
and aa
are the year, either in four digits or in two aaaa
和aa
是年份,四位数或两位数b
is the quarter number b
是季度数
What's the link between aaaa
and aa
? aaaa
和aa
之间有什么联系? Simple: aa = MOD(aaaa,100)
.简单: aa = MOD(aaaa,100)
。
From there you can start (realising that in Excel, concatenation is extremely simple: "TotalString" = "Total" & "String"
), so here we go (pseudo-code):从那里你可以开始(意识到在 Excel 中,连接非常简单: "TotalString" = "Total" & "String"
),所以我们开始(伪代码):
offset_number = 0
for aaaa = 1990 to 2019:
for b = 1 to 4:
resulting_string = aaaa & " FY" & aaaa & " FQ" & b & aaaa & " 31-Jan-" & MOD(aaaa,100) & " " & b
Starting_Cell.Offset(offset_number,0) = resulting_string
offset_number = offset_number + 1
Next b
Next aaaa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.