DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
@Alex Blakenburg gave me today a code here on the forum for running a change event on a userform combobox
but now im tryin to work it out..
the code work perfectly but i need, almost the same code, to run on/in the same combobox
the first code works on CB 2 - 17, at value 1, value2 value3, value4
but the 2nd has to run from 11 - 17, only when another value is choosen in the combobox (value 5)
so i tought to combine these 2 code....but i think it doesnt work on a change event
code 1, from Alex;
code 2 (to combine with 1)
but now im tryin to work it out..
the code work perfectly but i need, almost the same code, to run on/in the same combobox
the first code works on CB 2 - 17, at value 1, value2 value3, value4
but the 2nd has to run from 11 - 17, only when another value is choosen in the combobox (value 5)
so i tought to combine these 2 code....but i think it doesnt work on a change event
code 1, from Alex;
VBA Code:
Private Sub ComboBox1_Change()
Dim i As Long
Select Case Me.ComboBox1.Value
Case "ziek", "verlof", "feestdag", "bijzonder verlof"
For i = 2 To 17
With Me.Controls("ComboBox" & i)
.Enabled = False
.Value = "-"
.BackColor = RGB(224, 224, 224)
End With
Next i
Case Else
For i = 2 To 17
With Me.Controls("ComboBox" & i)
.Enabled = True
.Value = ""
.BackColor = RGB(255, 255, 255)
End With
Next i
End Select
End Sub
code 2 (to combine with 1)
VBA Code:
Private Sub ComboBox1_Change()
Dim i As Long
Select Case Me.ComboBox1.Value
Case "thuiswerk"
For i = 11 To 17
With Me.Controls("ComboBox" & i)
.Enabled = False
.Value = "-"
.BackColor = RGB(224, 224, 224)
End With
Next i
Case Else
For i = 2 To 17
With Me.Controls("ComboBox" & i)
.Enabled = True
.Value = ""
.BackColor = RGB(255, 255, 255)
End With
Next i
End Select
End Sub