Consulting

Results 1 to 6 of 6

Thread: Solved: Commandbutton visibility

  1. #1

    Solved: Commandbutton visibility

    Hi,

    I have some commandbuttons created on the worksheet which I don't
    want visible on workbook open.

    Tried
    [VBA]commandbutton1.visible = false[/VBA]

    both in workbook_open (just falls over)
    and worksheet_activate (doesn't make them invisible)

    Whats the correct way please?

    thanks
    Jon

  2. #2
    The button is a member of the sheet it is on, so:

    Sheet1.Commandbutton1.Visible=False
    should work.
    Provided you are using buttons from the control toolbox (ActiveX).
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    Thanks for reply.

    I created them in 'toolbars', 'visual basic' , 'control toolbox'
    and sheet2.commandbutton1.visible = false does not work in either
    workbook_open or worksheet_activate.

    Any ideas

    thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    THis works fine here

    [vba]

    Private Sub Worksheet_Activate()
    Me.CommandButton1.Visible = False
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    It works with the 'me' but not with sheet2 - however I had renamed sheet2 - maybe thats what the problem was.

    thanks for help guys
    regards

  6. #6
    You must use the codename of the sheet (as shown in the VBA properties window, (name) property).
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Posting Permissions

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