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. 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. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.