[英]Range of Cells from sheet 1 copied to sheet 4 in different cells
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.