ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Commandbutton? (https://www.excelbanter.com/excel-programming/366722-delete-commandbutton.html)

bluegnu[_2_]

Delete Commandbutton?
 

I'd like to be able to press one command button which deletes another
command button on a different worksheet - is this possible?

many thanks


--
bluegnu
------------------------------------------------------------------------
bluegnu's Profile: http://www.excelforum.com/member.php...o&userid=36108
View this thread: http://www.excelforum.com/showthread...hreadid=559824


Bob Phillips

Delete Commandbutton?
 
Attach this to the button macro

Worksheets("Sheet3").Buttons("Button 1").Delete


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"bluegnu" wrote in
message ...

I'd like to be able to press one command button which deletes another
command button on a different worksheet - is this possible?

many thanks


--
bluegnu
------------------------------------------------------------------------
bluegnu's Profile:

http://www.excelforum.com/member.php...o&userid=36108
View this thread: http://www.excelforum.com/showthread...hreadid=559824




Norman Jones

Delete Commandbutton?
 
Hi BlueGnu,

Try:

'=============
Private Sub CommandButton1_Click()
Dim MyButton As OLEObject
On Error Resume Next
Set MyButton = ThisWorkbook.Sheets("Sheet2"). _
OLEObjects("Commandbutton5")
On Error GoTo 0
If Not MyButton Is Nothing Then
MyButton.Delete
Else
MsgBox "CommandButton already deleted or not found"
End If

End Sub
'<<=============


---
Regards,
Norman



"bluegnu" wrote in
message ...

I'd like to be able to press one command button which deletes another
command button on a different worksheet - is this possible?

many thanks


--
bluegnu
------------------------------------------------------------------------
bluegnu's Profile:
http://www.excelforum.com/member.php...o&userid=36108
View this thread: http://www.excelforum.com/showthread...hreadid=559824




bluegnu[_3_]

Delete Commandbutton?
 

Thanks for the response.

I get the message "unable to get buttons property of worksheet class"
when I press the button. Any idea what I'm doing wrong? I've ensured
the button isn't locked or anything.


--
bluegnu
------------------------------------------------------------------------
bluegnu's Profile: http://www.excelforum.com/member.php...o&userid=36108
View this thread: http://www.excelforum.com/showthread...hreadid=559824


Bob Phillips

Delete Commandbutton?
 
Is it a control toolbox button?

Worksheets("Sheet3").OleObjects("Button 1").Delete


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"bluegnu" wrote in
message ...

Thanks for the response.

I get the message "unable to get buttons property of worksheet class"
when I press the button. Any idea what I'm doing wrong? I've ensured
the button isn't locked or anything.


--
bluegnu
------------------------------------------------------------------------
bluegnu's Profile:

http://www.excelforum.com/member.php...o&userid=36108
View this thread: http://www.excelforum.com/showthread...hreadid=559824




bluegnu[_5_]

Delete Commandbutton?
 

Thanks very much, they worked well

--
bluegn
-----------------------------------------------------------------------
bluegnu's Profile: http://www.excelforum.com/member.php...fo&userid=3610
View this thread: http://www.excelforum.com/showthread.php?threadid=55982



All times are GMT +1. The time now is 05:15 PM.

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