在Excel VBA中的工作表之间进行复制时出现错误1004

时间:2019-02-13 12:39:53

标签: excel vba

我得到

  

错误1004。

我尝试用F8调试。

Sub LoadNew()
    ...
    Call CopyColumn("New", "A1", "Total", "A1")
End Sub

Private Sub CopyColumn(FromSheet As String, FromColumn As String, ToSheet As String, ToColumn As String)
    If IsEmpty(Sheets(ToSheet).Range(ToColumn).Value) = True Then
        Sheets(FromSheet).Range(Range(FromColumn), Range(FromColumn).End(xlDown)).Copy Sheets(ToSheet).Range(ToColumn)
    Else
        Sheets(FromSheet).Range(Range(FromColumn), Range(FromColumn).End(xlDown)).Copy Sheets(ToSheet).Range(ToColumn).End(xlDown).Offset(1, 0)
    End If
End Sub

我希望将整列从一张纸复制到第二张纸。

0 个答案:

没有答案