2017-06-21 83 views
0

在VBA Excel中,第二次运行我的代码时出现自动化错误。 它如下:第二次运行Excel VBA自动化错误代码

Sheets("Panel Resumen").Select 
Rows("55:69").Select 
Selection.Copy 
Rows("55:55").Select 
Selection.Insert Shift:=xlDown 
Range("D25").Select 
Application.CutCopyMode = False 

而且它触发错误

Selection.Insert Shift:=xlDown 

我研究并得到了这个链接https://support.microsoft.com/en-us/help/178510/excel-automation-fails-second-time-code-runs 行了,但我不明白这是我失败的对象调用

+0

请参阅[如何避免选择](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros),可能会解决这个问题。 –

回答

0

不使用Select,这应该解决这个问题,我认为:

With Sheets("Panel Resumen") 
    .Rows("55:69").Copy 
    .Rows("55:55").Insert Shift:=xlDown 
End With 
Application.CutCopyMode = False 
相关问题