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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

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