0
Sub Macro5()
    '
    ' Macro5 Macro
    '
    
    '
    Dim wbk As Workbook
    Application.ScreenUpdating = False
    
    Set wbk = Workbooks.Open("g:\Work\EU Personal Assignment.xlsx")
        Range("O2:R2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Windows("Dashboard_for_Roshan.xlsm").Activate
        Range("A65536").End(xlUp).Select
        ActiveSheet.Paste
        Windows("EU Personal Assignment.xlsx").Activate
        Range("A2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
    
    
        Windows("Dashboard_for_Roshan.xlsm").Activate
        Range("E65536").End(xlUp).Select
        ActiveSheet.Paste
        Windows("EU Personal Assignment.xlsx").Activate
        Range("AC2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
    
        Windows("Dashboard_for_Roshan.xlsm").Activate
        Range("F65536").End(xlUp).Select
        ActiveSheet.Paste
    
    
    
    Call .wbk.Close(False) <- i get the error here 
    
    
End Sub

在 excel 之前End(xlUp),我正在使用

Cells(Cells(Rows.Count, "A").End(xlUp).Row + 1, "A").Select

但我无法使用它粘贴数据。

编辑:错误是..wbk 之前的额外错误,但现在它替换了前一行数据,而我希望它将数据粘贴到最后使用的行下方。有什么建议吗?

4

1 回答 1

0

要粘贴到数据下方,您需要在粘贴之前选择数据下方的第 1 行

要使用与您尝试相同的方法:

Range("A65536").End(xlUp).Offset(1, 0).Select

或者作为替代方法尝试:

Cells(ActiveSheet.UsedRange.Rows.Count + 1, 1).Select

要解决您的错误,请尝试使用:

wbk.Close
于 2013-06-17T12:49:46.757 回答