ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Destroy command button with a Macro? (https://www.excelbanter.com/excel-discussion-misc-queries/2316-destroy-command-button-macro.html)

grasping@straws

Destroy command button with a Macro?
 
Any way to delete a command button once it's been clicked on?
(Thinking about a template with a one-time use button)

tm

Bernie Deitrick

tm,

Assuming the commandbutton was off of the control toolbox: At the end of
the Private Sub CommandButton1_Click() code, use a line like:

Worksheets("Sheet1").Shapes("CommandButton1").Dele te

HTH,
Bernie
MS Excel MVP

"grasping@straws" wrote in message
...
Any way to delete a command button once it's been clicked on?
(Thinking about a template with a one-time use button)

tm




Paul B

tm, if you just want to delete the button use something like this

Private Sub CommandButton1_Click()
Range("A1") = "test"
ActiveSheet.Shapes("CommandButton1").Delete
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"grasping@straws" wrote in message
...
Any way to delete a command button once it's been clicked on?
(Thinking about a template with a one-time use button)

tm




grasping@straws

On Tue, 21 Dec 2004 11:18:41 -0500, "Paul B"
wrote:

D'oh!..."Shapes".....ah, well...I'm learning (slowly)

Thanks both o' you.

tm


All times are GMT +1. The time now is 08:19 PM.

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