Deleting non-ActiveX Comboboxes

Jordo82

New Member
Joined
Aug 31, 2004
Messages
47
I have an old file with several hundred comboboxes that I need to get rid of. The comboboxes were created using the Forms toolbar, not the Control Toolbox.

Is there any way to reference these kind of comboboxes in VB so that a macro could delete them? If not, is there any way to select/delete more than one at a time?

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
This macro will remove all Objects from a page.

Sub RemoveObjects()
Dim PicObj As Object
For Each PicObj In ActiveSheet.Shapes 'OLEObjects
'MsgBox PicObj.Name
ActiveSheet.Shapes(PicObj.Name).Cut
Next PicObj
End Sub

Beware:
It will take pictures and Control objects along with Objects from the Forms Toolbox.
 
Upvote 0
Why not just Edit>Goto...Special...Objects and then hit delete?
 
Upvote 0
Thanks both for the reply!

I should have been more specific in my post. I need to delete several hundred comboboxes of a certain type, leaving many comboboxes on the sheet untouched. I was able to use most of Datsmart's code though. I simply added an if statement dealing with the object name to limit the deletions to just the comboboxes I wanted. Thanks again!
 
Upvote 0
Jordo,

Could you list your code so we can all learn how to make the selection?

Thanks,

Datsmart
 
Upvote 0
I inserted an if statement that limited the deletions to just Comboboxes. I also added a variable num, which is the number at the end of the Combobox name. By changing the condition of num in the if statement, you can specify exactly which comboboxes will be deleted.

Sub RemoveObjects()
Dim PicObj As Object
Dim num As Integer

For Each PicObj In ActiveSheet.Shapes 'OLEObjects
num = Right(PicObj.Name, 1)
If Left(PicObj.Name, Len(PicObj.Name) - 2) = "Drop Down" And num < 3 Then ActiveSheet.Shapes(PicObj.Name).Cut
Next PicObj
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,179
Messages
6,183,389
Members
453,159
Latest member
dassuz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top