PDA

View Full Version : Make a command button self-distruct



Jack Brown
05-30-2017, 02:30 PM
Excuse my ignorance, but how can I make a command button self destruct?
I'm making an excel 'zerg rush' style game thingy.
:yes
Thanks

mdmackillop
05-30-2017, 03:24 PM
Like this?

Private Sub CommandButton1_Click()
MsgBox "About to self destruct"
Me.Shapes("CommandButton1").Delete
End Sub

Jack Brown
05-30-2017, 04:10 PM
Perfect! Thanks!

Jack Brown
05-31-2017, 07:15 PM
This is probably quite an unusual question, but how could I make a command button self destruct if another command button lands on it? I cannot record this as I do not know which command button will land on what command button...
Thanks:rofl:

mikerickson
05-31-2017, 11:53 PM
Buttons don't land.

What are you trying to do.

GTO
06-01-2017, 05:36 AM
Buttons don't land.

:outtahereBut if they never land, how do they get on the sheet?

(Sorry Mike, I just couldn't resist)

Jan Karel Pieterse
06-01-2017, 06:38 AM
Please be aware that removing or adding an ActiveX control on a worksheet resets the code in the file in question.

mikerickson
06-01-2017, 06:56 AM
Rather than destroying controls, it is probably better to make them not visible.

Jack Brown
06-01-2017, 10:24 PM
Ok. I was trying to make a 'zerg rush' game where little squares (command buttons) jump round and when one lands on your square your square 'dies'.