RE: cutting command buttons

cart0250

Active Member
Joined
Jun 24, 2006
Messages
275
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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
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
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
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?
 

cart0250

Active Member
Joined
Jun 24, 2006
Messages
275
RE: cutting command buttons

yes, that is exactly want I needed. Thanks
 

Forum statistics

Threads
1,137,200
Messages
5,680,125
Members
419,884
Latest member
james888sa

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
Top