RE: cutting command buttons

cart0250

Active Member
Joined
Jun 24, 2006
Messages
284
Office Version
  1. 2016
Platform
  1. Windows
RE: cutting command buttons

I have a series of command buttons I would like to remove during a macro. Is there a quicker way to do this than the obvious code:

ActiveSheet.Shapes("CommandButton1").Cut
ActiveSheet.Shapes("CommandButton2").Cut
ActiveSheet.Shapes("CommandButton3").Cut
...
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi

If all the shapes on the sheet are commandbuttons then something like

Code:
for i = activesheet.shapes.count to 1 step -1
  activesheet.shapes(i).delete
next i


Tony
 
Upvote 0
Hello cart0250,
To remove all (and only the) CommandButtons from the worksheet (leaving all other
objects) you can use something like this.
Code:
Sub RemoveCmdBtns()
Dim CmdBtn As Object
For Each CmdBtn In ActiveSheet.OLEObjects
  If TypeOf CmdBtn.Object Is MSforms.CommandButton Then CmdBtn.Delete
Next
End Sub

Is that what you're looking to do?
 
Upvote 0
RE: cutting command buttons

yes, that is exactly want I needed. Thanks
 
Upvote 0

Forum statistics

Threads
1,218,560
Messages
6,143,200
Members
450,469
Latest member
brent3162

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