列表框项目清除在VBA Excel中不起作用 [英] Listbox Item Clearing is Not Working in VBA Excel

查看:239
本文介绍了列表框项目清除在VBA Excel中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带有一个按钮的两个列表框用户可以单击按钮将所有列表项从listbox1移动到listbox2。它在excel 2007和& ;; 2013年但是

当listbox1变空时应用程序将在2016年EXCEL重新启动

I have a two list boxes with one button when the user can click the button move all the list item from listbox1 to listbox2. its working fine in excel 2007 & 2013 but when the listbox1 is becomes empty app is getting restarted IN EXCEL 2016.

我的代码是

For i = 1 To ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).listCount
   ThisWorkbook.Sheets("MultiSheet").ListBoxes(strTolb).AddItem ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).List(1)
   ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).RemoveItem (1)
Next i


Here  strFromLb  是
清除值但是当它清除最后一个值时,我的VBA应用程序excel已重新启动。

Here strFromLb is clearing the values but when it clearing last value my VBA App is excel has been restarted.

然后我尝试了清除列表框的代码

Then I have tried code to clear the listbox

ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).ControlFormat.RemoveAllItems
ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).Items.Clear


错误是

The error is


"对象不支持属性或方法"

"Object doesnt supported to property or method"


然后

Then

ThisWorkbook.Sheets("MultiSheet").ListBoxes(strFromlb).Clear


这段代码我得到400错误。所以请帮助我。

This code I got the 400 error. so kindly help me.

推荐答案

Re:listbox error



尝试用"ListBox"替换"ListBoxes"的所有实例。
b $ b据我所知,"ListBoxes""在VBA中不存在。



Re: listbox error

Try replacing all instances of "ListBoxes" with "ListBox".
As far as I am aware, "ListBoxes" does not exist in VBA.

'---
Jim Cone

美国俄勒冈州波特兰市
https://goo.gl/IUQUN2  (Dropbox)
'---
Jim Cone
Portland, Oregon USA
https://goo.gl/IUQUN2 (Dropbox)


这篇关于列表框项目清除在VBA Excel中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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