Hi All Expert,
I have one comboBox depend on another 4 comboBoxes. It would be short to create change event
Private Sub ComboBox27_Change()
If Me.ComboBox27.Value <> Empty Then
For i = 28 To 31
With Me.Controls("ComboBox" & i)
.Clear
.Enabled = False
End With
Next i
Else
For i = 28 To 31
With Me.Controls("ComboBox" & i)
.Enabled = True
.Clear
.List = wsData.Range("AA2:AA11").Value
End With
Next i
End If
End Sub
However, each of 4 ComboBoxes also depend on a single comboBox as described above. Thus, I have to create 4 times change event to ensure it working fine. Is there any method to create only one change event instead of 4 as described below?
Private Sub ComboBox28_Change()
Private Sub ComboBox29_Change()
Private Sub ComboBox30_Change()
Private Sub ComboBox31_Change()
'\\The same code use for all change event
If Me.ComboBox28.Value <> Empty Or _
Me.ComboBox29.Value <> Empty Or _
Me.ComboBox30.Value <> Empty Or _
Me.ComboBox31.Value <> Empty Then
With Me.ComboBox27
.Clear
.Enabled = False
End With
Else
With Me.ComboBox27
.Enabled = True
.Clear
.List = wsData.Range("AA2:AA11").Value
End With
End If
Bookmarks