VBA copy and move data range
I am working on setting up several spreadsheets at work to optimize my work. I am still new to VBA.
I am trying to cut a range of data in column (E6: E14) from Sheet1 and wrap the data before inserting the data into the next available row in column A of sheet 2. Here is the code I have written so far from trial and error. Every time I run the code, I get a "1004" runtime error. I am trying to create a "database" in Sheet2. Any help appreciates this.
Sub Test()
Worksheets("Sheet1").Range("E6:E14").Cut
Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
End Sub
Thanks for the help!
FHY
+3
source to share
1 answer
PasteSpecial is not available with the .Cut method, but not the .Copy method. When i changed
Worksheets("Sheet1").Range("E6:E14").Cut
to
Worksheets("Sheet1").Range("E6:E14").Copy
everything worked fine. If you want everything to be removed afterwards, you can always just do:
Sub Test()
Worksheets("Sheet1").Range("E6:E14").Copy
Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
Worksheets("Sheet1").Range("E6:E14").Clear
End Sub
+3
source to share