在数据表VBA Excel2010 ActiveX中插入新行 [英] Insert new row in data table VBA Excel2010 ActiveX

查看:107
本文介绍了在数据表VBA Excel2010 ActiveX中插入新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据表中插入一行。当我手动尝试(选择行,插入新行)时,它工作正常,但是当我尝试将其添加到ActiveX按钮(!)内的宏中时,它说运行时错误438:对象不支持此操作方法。如果我在通常的宏中而不是在按钮内尝试微距,它也可以正常工作。

I want to insert a row in my data table. When I try it manually (select row, insert new row) it works just fine, but when I try to add it into my macro, which is inside an ActiveX button(!) it says "Runtime error 438: Object does not suppoort this method". If I try the mecro in a usual macro, not inside the button, it works fine aswell.

如何摆脱这个问题?

Set wsd = Sheets("Data")
wsd.Select                      
With wsd
.Rows("5:5").Select
.Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove 'Here appears the error
End With

非常感谢您的帮助。

推荐答案

您不需要选择。

Sub test()
Set wsd = Sheets("Data")
With wsd
    .Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove 
End With

End Sub

这篇关于在数据表VBA Excel2010 ActiveX中插入新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆