Removing a macro button after execution

B

Bishop

I have created a button and have assigned a macro to it. How do I code the
existing macro to delete the button once the macro has executed?
 
P

Per Jessen

Hi

Why not just make the button invisible?
Well, the below macro gives an example of both solutions.


Private Sub CommandButton1_Click()
msg = MsgBox("Hello")
Me.CommandButton1.Visible = False
'Me.CommandButton1.Delete
End Sub

Regards,
Per
 
D

Don Guillett

The trick is to know the name

Sub deleteshapeafterrunningmacro()
MsgBox "hi"
With ActiveSheet
.Shapes("Rectangle 3").Cut
End With
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

Top