I am having problems coping cells from one sheet to another sheet. Error script out of range. Seems so simple to do but is not working. Any suggestions from the pros.
Sub Button1_Click()
Sheet4.Select
'Copy the data
Sheets("Sheet1").Range("A7").Copy
Sheets("Sheet1").Range("D7").Copy
Sheets("Sheet1").Range("G7").Copy
Sheets("Sheet1").Range("C10").Copy
Sheets("Sheet1").Range("A12").Copy
Sheets("Sheet1").Range("C12").Copy
Sheets("Sheet1").Range("A14").Copy
Sheets("Sheet1").Range("A16").Copy
Sheets("Sheet1").Range("A29").Copy
'Activate the destination worksheet
Sheets("Sheet4").Activate
'Select the target range
Sheets("Sheet4").Range("A6").Paste
Sheets("Sheet4").Range("E6").Paste
Sheets("Sheet4").Range("H6").Paste
Sheets("Sheet4").Range("G8").Paste
Sheets("Sheet4").Range("A10").Paste
Sheets("Sheet4").Range("G10").Paste
Sheets("Sheet4").Range("A12").Paste
Sheets("Sheet4").Range("A14").Paste
Sheets("Sheet4").Range("A19").Paste
'Paste in the target destination
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
If you don't need formatting, I'd do something like
Set ws1 = WorkSheets("Sheet1")
Set ws4 = WorkSheets("Sheet4")
With ws4
.Range("A6").Value = ws1.Range("A7").Value
.Range("E6").Value = ws1.Range("D7").Value
.Range("H6").Value = ws1.Range("G7").Value
.Range("G8").Value = ws1.Range("C10").Value
.Range("A10").Value = ws1.Range("A12").Value
.Range("G10").Value = ws1.Range("C12").Value
.Range("A12").Value = ws1.Range("A14").Value
.Range("A14").Value = ws1.Range("A16").Value
.Range("A19").Value = ws1.Range("A29").Value
End With
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.