PDA

View Full Version : CommandButton &i.Elabled = False



sj72053
06-23-2008, 10:51 PM
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 ....

JimmyTheHand
06-23-2008, 10:55 PM
For i = 1 to 10
Userform1.Controls("CommandButton" & i).Enabled = False
Next

sj72053
06-23-2008, 11:03 PM
Thank you Jimmy, it's working now .... :-)