Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Disabling buttons on worksheets using vba

  1. #1
    New Member
    Join Date
    Sep 2002
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Disabling buttons on worksheets using vba

    Hi there,

    Can anyone help me I wish to disable some buttons on a worksheet so to guide the user around the page step by step can anyone help me with the referencing of the button

    i.e Worksheet("Main Menu").cmdButton.enabled = False

    Cheers

  2. #2
    Board Regular
    Join Date
    Nov 2003
    Posts
    230
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Disabling buttons on worksheets using vba

    Hey redbull8vodka

    The correct code would be :

    Code:
    Sheets("Main Menu").CommandButton.Enabled = False
    where NumberHere represents the actual CommandButton number.

    You can also loop through the controls and disable all those command buttons that are not named "Whatever" using the CmdButton control type i.e

    Code:
    For Each ctl in Controls
    If ctl.Type = CmdButton Then
    If ctl.Name <> CommandButton1 Then
    ctl.Enabled = False
    End If
    End If
    Next ctl
    Try That

    anvil19
    :o

  3. #3
    New Member
    Join Date
    Dec 2014
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Disabling buttons on worksheets using vba

    Quote Originally Posted by anvil19 View Post
    Hey redbull8vodka

    The correct code would be :

    Code:
    Sheets("Main Menu").CommandButton.Enabled = False
    where NumberHere represents the actual CommandButton number.

    You can also loop through the controls and disable all those command buttons that are not named "Whatever" using the CmdButton control type i.e

    Code:
    For Each ctl in Controls
    If ctl.Type = CmdButton Then
    If ctl.Name <> CommandButton1 Then
    ctl.Enabled = False
    End If
    End If
    Next ctl
    Try That

    anvil19
    :o


    hi, can anyone tell me how we suppose to disable the button which we take it from "Form control" i am able to do with activex button but if i take it from Form control i am not able to disable button.

    Sub Button1_Click()
    Dim b1 As Button
    Set b1 = ActiveSheet.Buttons("Button 1")
    b1.Font.ColorIndex = 15
    b1.Enabled = False

    MsgBox "hello"
    End Sub


    i have written above code and i have try to disable button with changing color but still msgbox "hello" showing every time but "hello" should be show only one time. can anyone help me on this?













User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.
     


DMCA.com