Consulting

Results 1 to 7 of 7

Thread: Solved: worksheet buttons

  1. #1
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location

    Solved: worksheet buttons

    Hi, I have many buttons in my worksheets and when the user open, they have to enter the password (i use input box for that), if they don't enter the password or enter it wrong, i want visible to be false to all these buttons.

    I can't seem to find the name of the buttons. how to I references these button and how do i get to the name. I can only assign a macro to them.

    Thanks in advance for your help.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings chungtinhlak,

    How did you create the buttons? Or, more accurately, from which toolbar did they come from? The Forms toobar, or the vba toolbar (the Control Toolbox)?

    Mark

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Select the button, and you will see its name in the names box at top left.
    ____________________________________________
    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

  4. #4
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    ok, so i have 4 buttons (1 - 4) in 4 of my worksheets.

    how come this doesn't work,

    [VBA]worksheets(1).button4.visible = false[/VBA]

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,206
    Location
    If it is a form button then it should be...

    [VBA]Sheet1.Shapes("Button 1").Visible = False[/VBA]

    If it is an ActiveX command button then it should be...

    [VBA]Sheet1.CommandButton1.Visible = False[/VBA]

    Hope this helps.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2404, Build 17531.20128

  6. #6
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    thanks, that really help.

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If the are forms toolbar buttons, you van use

    [vba]

    Worksheets("Sheet1").Buttons("Button 1").Visible = False
    [/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

Posting Permissions

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