【发布时间】:2019-07-05 14:07:53
【问题描述】:
我尝试将最后一整行复制到另一张纸上,但失败了 使用这种方法,它只会将单个单元格复制到所有行
Dim lrow As Long
With Worksheets("101")
lrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("B" & lrow - 1, "M" & lrow).Copy
Worksheets("EOM").Range("B4").PasteSpecial xlPasteAll
End With
这段代码会报错
Dim shRead As Worksheet
Set shRead = ThisWorkbook.Worksheets("101")
Dim lastRow As Long, lastCol As Long
lastRow = shRead.Cells(shRead.Rows.Count, 2).End(xlUp).Row
lastCol = shRead.Cells(lastRow, shRead.Columns.Count).End(xlToLeft).Column
With shRead
shRead.Range(lastRow, lastCol).Copy_
Worksheets("EOM").Range(B4, M4)
End With
错误
shRead.Range(lastRow, lastCol).Copy_
【问题讨论】:
-
下划线
.Copy _前必须有一个空格。 • 并且Range(lastRow, lastCol)应该是Cells(lastRow, lastCol)。 • 并且Range(B4, M4)必须是Range("B4", "M4") -
@Pᴇʜ 先生,感谢您抽出宝贵时间,但这并没有尝试过。