[英]How to copy and paste always one row below
I have been working on code to copy and paste from one worksheet to another.我一直在研究从一个工作表复制和粘贴到另一个工作表的代码。 The data that I need to copy will always be at
A1:E1
, however, I need to always paste one row below.我需要复制的数据总是在
A1:E1
,但是,我需要总是在下面粘贴一行。 I will run it everyday, so for instance if today I paste on cells A1:E1
, then tomorrow I would need to paste on A2:E2
and on the next day A3:E3
... I wrote the code below which works but is not as dynamic as I need it to be.我会每天运行它,例如,如果今天我粘贴在单元格
A1:E1
,那么明天我需要粘贴在A2:E2
和第二天A3:E3
......我写了下面的代码,但它是有效的不像我需要的那样动态。 I would appreciate your help我很感激你的帮助
Thank you谢谢
Sub Copy_range()
Worksheets("Dividends").Range("A1:E1").copy
Worksheets("Draft").Range("A1:E1").PasteSpecial
End Sub
This will make it more modular by skipping down past all used cells then pasting the value on the next empty cell.通过跳过所有使用过的单元格然后将值粘贴到下一个空单元格上,这将使其更加模块化。
Sub Copy_range()
' edit line below to change where data will be copied from
Worksheets("Dividends").Range("A1:E1").Copy ' copy the value
' select the first cell on the "Draft" sheet
Worksheets("Draft").Select
ActiveSheet.Range("A1").Select
Dim count As Integer
count = 1
'skip all used cells
Do While Not (ActiveCell.value = None)
ActiveCell.Offset(1, 0).Range("A1").Select
count = count + 1
Loop
' edit line below to change alphabetical values of where data will be placed
Worksheets("Draft").Range("A" & count & ":E" & count).PasteSpecial ' paste the value
' at Acount:Ecount where count is the current row i.e. A11:E11
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.