Remove buttons from worksheet programmatically

  • Thread starter Thread starter Albert Browne
  • Start date Start date
A

Albert Browne

Hi.

I have a number of worksheets that I copy to a new workbook. These
worksheets have a number of command buttons. I would like to remove these
buttons after copying. Is this possible with VBA?


Thanks.

Albert
 
Try this Albert:

'====================
Sub DeleteAllButtons()

Dim mySheet As Worksheet
Dim MyButton As OLEObject

For Each mySheet In ActiveWorkbook.Worksheets

For Each MyButton In mySheet.OLEObjects
If TypeOf MyButton.Object Is MSForms.CommandButton Then
MyButton.Delete
End If
Next MyButton

Next mySheet

End Sub
'====================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top