+ Reply to Thread
Results 1 to 6 of 6

Delete Commandbutton?

  1. #1
    Registered User
    Join Date
    07-06-2006
    Location
    Southsea
    MS-Off Ver
    2003
    Posts
    16

    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

  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  3. #3
    Registered User
    Join Date
    07-06-2006
    Location
    Southsea
    MS-Off Ver
    2003
    Posts
    16
    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.

  4. #4
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  5. #5
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  6. #6
    Registered User
    Join Date
    07-06-2006
    Location
    Southsea
    MS-Off Ver
    2003
    Posts
    16
    Thanks very much, they worked well!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1