Hi,
I'm working with Excel 2003 VBA. I have a UserForm with 10 ComboBoxes.
And I have an general input. The ComBoboxes are filled dynamically , they have more or less items depending on this input.
When this input is less than a defined value, I disable e.g. ComboBox10. and so on. Below is part of the code (how I fill and how I disable).
I would like to know an efficient way to write a less code as possible when I need to disable several ComboBoxes.
Code used to fill part of them using an array:
etc etc....VB Code:
With ComboBox2 For index = 1 To Num .AddItem RackID(index) Next index End With With ComboBox3 For index = 1 To Num .AddItem RackID(index) Next index End With
Code used to disable them:
I can say that Im a newbie. Thanks for your help,VB Code:
If Num = 5 Then 'MyCell8 = 40000 With ComboBox6 .Enabled = False .BackColor = &H8000000F End With With ComboBox7 .Enabled = False .BackColor = &H8000000F End With With ComboBox8 .Enabled = False .BackColor = &H8000000F End With With ComboBox9 .Enabled = False .BackColor = &H8000000F End With With ComboBox10 .Enabled = False .BackColor = &H8000000F End With End If
Mafe![]()




Reply With Quote