我想跳过为了速度而逐个单元格的复制 - 如果我想要复制除第一行以外的整个范围,我该怎么做:
Worksheets("sheet1").Range("A2:A").Copy Worksheets("sheet2").Range("F2:F")
工作?这两个工作表也将始终具有相同的行数。上述内容会导致应用程序定义/对象定义错误。
答案 0 :(得分:0)
使用此
With Worksheets("sheet1") 'reference "sheet1" worksheet
.range("A2", .Cells(.Rows.Count, "A").End(xlUp)).Copy Worksheets("sheet2").range("F2") ' copy referenced worksheet column A range from row 2 down to last not empty one and paste it to "sheet2" worksheet starting from its cell "F2"
End With
答案 1 :(得分:0)
或者
With Worksheets("sheet1")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Worksheets("sheet2").Range("F2:F" & lastRow) = .Range("A2:A" & lastRow)
End With