Deleting Command Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When using the following code I receive an
error...ActiveSheet.Shapes("CommandButton1").Delete

I am assuming it is becuase I have placed this code within the event
CommandButton1_Click(). I would like to get this to work becuase after I
execute my other code I am self desctructing the code and the button.

Help is greatly appreciated!
 
Try this:

Private Sub CommandButton1_Click()
Application.OnTime Now, "KillCmdbtn"
End Sub

and in a regular module:

Sub KillCmdBtn()
ActiveSheet.Shapes("CommandButton1").Delete
End Sub

--
Jim Rech
Excel MVP
| When using the following code I receive an
| error...ActiveSheet.Shapes("CommandButton1").Delete
|
| I am assuming it is becuase I have placed this code within the event
| CommandButton1_Click(). I would like to get this to work becuase after I
| execute my other code I am self desctructing the code and the button.
|
| Help is greatly appreciated!
 

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