ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing a macro button after execution (https://www.excelbanter.com/excel-programming/426088-removing-macro-button-after-execution.html)

Bishop

Removing a macro button after execution
 
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?

Per Jessen

Removing a macro button after execution
 
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

"Bishop" skrev i meddelelsen
...
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?



Don Guillett

Removing a macro button after execution
 
The trick is to know the name

Sub deleteshapeafterrunningmacro()
MsgBox "hi"
With ActiveSheet
.Shapes("Rectangle 3").Cut
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Bishop" wrote in message
...
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?




All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com