vba 查找和删除 Excel 工作表中的所有组合框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24252251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find and Delete all Comboboxes in Excel Sheet
提问by whispersan
I want to use VBA to delete all comboboxes in a sheet (form control type not active X)
我想使用 VBA 删除工作表中的所有组合框(表单控件类型未激活 X)
I have
我有
For Each s In ActiveSheet.Shapes
s.Delete
Next s
The problem is it deletes all my shapes, and I'm having trouble finding the logic just to delete comboboxes (which have different names)
问题是它删除了我所有的形状,我很难找到删除组合框(名称不同)的逻辑
Thanks for any help!
谢谢你的帮助!
回答by Tim Williams
With ActiveSheet.DropDowns
Do While .Count > 0
.Item(1).Delete
Loop
End With
or just
要不就
activesheet.dropdowns.delete
回答by Gary's Student
If the only Forms you have are these comboboxes, then:
如果您拥有的唯一表单是这些组合框,则:
Sub qwerty()
Dim s As Shape
For Each s In ActiveSheet.Shapes
If s.Type = 8 Then
s.Delete
End If
Next s
End Sub