【发布时间】:2014-06-06 15:11:33
【问题描述】:
我只是想将工作表上的一个范围复制到不同工作表上的另一个范围。据我了解,该方法是 Range1.Copy(DestRange) 我需要像这样指定工作表吗? Worksheets("sheet1").Range1.Copy(Worksheets("Destination").DestRange)
我的代码抛出一个错误: 运行时错误 1004: 对象“范围”的方法“复制”失败
我的代码:
Sub adsadsf()
Dim currentR As Range
Dim rawIput As Worksheet
Dim excitationWs As Worksheet
Set currentR = Range("B2", Range("B2").End(xlDown))
currentR.Select
Set rawInput = Worksheets("rawInput")
Set excitationWs = Worksheets("Excitation Curve")
'none of these work. all throw same error
'currentR.Copy (Range("H1"))
'currentR.Copy (Range("H1"))
'currentR.Copy (excitationWs.Range("A1"))
rawInput.Copy (excitationWs.Range("A1"))
End Sub
【问题讨论】:
-
currentR.Copy Range("H1")不带括号。如果您想复制所有单元格,rawInput.Copy (excitationWs.Range("A1"))也应该是rawInput.Cells.Copy excitationWs.Range("A1")(效率低 - 最好复制工作表)。这可能很有趣:What is the difference between entering parameters in these four different ways -
@simoco - 如果您在评论中回答问题,您希望如何获得高分? (+1)
-
@simoco 谢谢!这一直把我逼到一堵墙,我真的不明白一些有括号的方法之间的逻辑,然后突然有括号会导致一切陷入困境。你太棒了