如果您尝试将范围从一张纸复制到另一张纸,则不需要循环,也不需要选择。您可以使用不使用剪贴板的复制语法。
尝试这个:
Sub CopyRangeToAnotherSheet()
Dim source As Worksheet
Dim target As Worksheet
Set source = ActiveWorkbook.Sheets("Sheet1")
Set target = ActiveWorkbook.Sheets("Sheet2")
source.Range("D4:E200").Copy target.Range("ALB3")
End Sub
要将源范围复制到工作簿中除源工作表之外的所有工作表,请尝试以下操作:
Sub CopyToAllSheets()
Dim ws As Worksheet
For Each ws In Worksheets
CopyRangeToAnotherSheet (ws.Name)
Next
End Sub
Sub CopyRangeToAnotherSheet(targetName As String)
Dim source As Worksheet
Dim target As Worksheet
Set source = ActiveWorkbook.Sheets("Sheet1")
Set target = ActiveWorkbook.Sheets(targetName)
If target.Name <> source.Name Then
source.Range("D4:E200").Copy target.Range("ALB3")
End If
End Sub