我想复制工作表 3 的单元格范围(C1:Z1000)并将它们粘贴到工作表 1 的第一个空列(在第 1 行)。下面的代码块在最后一行: source.Range("C1:Z1000").Copy destination.Cells(1, emptyColumn)
Sub CopyRange()
Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long
Set source = Sheets("Sheet3")
Set destination = Sheets("Sheet1")
'find empty Column (actually cell in Row 1)'
emptyColumn = destination.Cells(1, destination.Columns.Count).End(xlUp).Column
If emptyColumn > 1 Then
emptyColumn = emptyColumn + 1
End If
source.Range("C1:Z1000").Copy destination.Cells(1, emptyColumn)
End Sub