PDA

View Full Version : Code required to remove a button



MontySharpei
09-18-2008, 05:18 AM
Hello,

attached is a sheet that when button 1 is pressed a userform is brought up. When text is added and submit is pressed the text is copied to cell A1. When the cancel button is pressed the userform is closed.

Now the bit where i'm stuck!

I want to press the remove button on the userform and what this will do is remove button 1 from the sheet, leaving any text that was previously submitted still there ?
anybody any ideas on the code required to do this ??

Thanks in advance....

MontySharpei
09-18-2008, 05:20 AM
Doh forgot to add the sheet !!!!

Hello,

attached is a sheet that when button 1 is pressed a userform is brought up. When text is added and submit is pressed the text is copied to cell A1. When the cancel button is pressed the userform is closed.

Now the bit where i'm stuck!

I want to press the remove button on the userform and what this will do is remove button 1 from the sheet, leaving any text that was previously submitted still there ?
anybody any ideas on the code required to do this ??

Thanks in advance....

Bob Phillips
09-18-2008, 05:38 AM
Private Sub CommandButton3_Click()
Worksheets("Sheet1").Buttons("Button 1").Delete
End Sub

MaximS
09-18-2008, 05:51 AM
I found couple times within my macros than deleted button is causing problems, especially with debugging.

Only solution is placing below code at the end of the macro.



Private Sub CommandButton3_Click()
Worksheets("Sheet1").Buttons("Button 1").Delete
End Sub



or using rectangle as a button and deleting rows/columns.

MontySharpei
09-18-2008, 10:41 AM
Thank you once again xld works perfectly !