我只是想将工作表上的一个范围复制到另一个工作表上的另一个范围。据我所知,该方法是Range1.Copy(DestRange) 我需要指定工作表吗? 工作表( “工作表Sheet”)。Range1.Copy(工作表( “目的地”)。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
答案 0 :(得分:0)
试试这个(如果需要,你可以添加工作表变暗)
Dim currentR As Range
Dim destR As Range
Set currentR = Worksheets("rawInput").Range("B2", Range("B2").End(xlDown))
Set destR = Worksheets("Excitation Curve").Range("A1")
currentR.Cells.Copy destR