【发布时间】:2019-10-22 14:04:00
【问题描述】:
我正在尝试从所有行中剪切数据,直到“摘要”表中的最后一行,并将其粘贴到“历史”表中的下一个空白行,但我收到此错误:PasteSpecial 方法或 Range 类失败了。
Sub HistoricalData()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Dim LastRow As Integer
LastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).row
Set copySheet = Worksheets("Summary")
Set pasteSheet = Worksheets("Historical")
copySheet.Range("A2:V2" & LastRow).Cut
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
提前致谢!
【问题讨论】:
-
我认为您以错误的方式使用函数
PasteSpecial。如果您剪切数据,则不能使用 pastespecial。您应该首先复制数据和PasteSpecial的值,然后您可以删除相同的范围。 -
Range("A2:V" & LastRow.