Consulting

Results 1 to 3 of 3

Thread: CommandButton &i.Elabled = False

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    10
    Location

    CommandButton &i.Elabled = False

    Hi All,
    I have a UserForm, with 10 CommandButtons starting from CommandButton1, CommandButton2 ....CommandButton10
    On click of a button , i want to Disable all the 10 commandbuttons
    CODE :-
    ~~~~~
    ___________________________________________
    For i = 1 to 10
    CommandButton1.Elabled = False
    CommandButton2.Elabled = False
    CommandButton3.Elabled = False
    .
    .
    .
    .
    CommandButton10.Elabled = False
    Next i
    ___________________________________________
    Requirement :-
    ~~~~~~~~~~~
    How can i write the same code by NOT writing the same statement "CommandButtoni.Enabled =False " for 10 times
    -> When tried as follows the code is NOT working ....
    ___________________________________________
    For i = 1 to 10
    CommandButton &i.Elabled = False
    Next i
    ___________________________________________
    Can anyone help me in this ....

  2. #2
    [VBA]For i = 1 to 10
    Userform1.Controls("CommandButton" & i).Enabled = False
    Next[/VBA]
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  3. #3
    VBAX Regular
    Joined
    Jun 2008
    Posts
    10
    Location
    Thank you Jimmy, it's working now .... :-)

Posting Permissions

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