执行macor excel(1004)vba

时间:2015-11-25 14:32:49

标签: excel vba excel-vba button

当我尝试通过我在工作簿上绘制的按钮运行以下宏时,我得到一个错误(1004)。宏看起来像这样:

Sub copy_data()
' Copy incident_id and ticket_id from raw_incidents
    Sheets("Raw_Incidents").Select
    Range("Raw_incident[[id]:[ticket_id]]").Select
    Selection.Copy
    Sheets("Report").Select
    Range("Report[[incident_id]:[ticket_id]]").Select
    ActiveSheet.Paste

' Copy ticket_id from raw_old_ticket_support
    Sheets("Raw_Old_Support_Tickets").Select
    Range("A5").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Report").Select

' Function found on this page:    http://stackoverflow.com/questions/14957994/select-first-empty-cell-in-column-f-starting-from-row-1-without-using-offset
    Range("A8:A" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Select
    Range(Selection.Cells(1, 2), Selection.Cells(1, 2).End(xlDown)).Select
    ActiveSheet.Paste

    ActiveSheet.Range("Report[#Tout]").RemoveDuplicates Columns:=2, Header:=xlYes
End Sub

错误发生在最后一行:

ActiveSheet.Range("Report[#Tout]").RemoveDuplicates Columns:=2, Header:=xlYes

然而,当我从编辑器运行宏时,按下运行按钮,它工作正常。

可能是什么问题?

0 个答案:

没有答案