DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
Can anyone help me with this one?
I've got a userform combobox (dropdown) with about 6 items, but there are 3 value's in, that when sellected, the other userform comboboxes needs to be blocked (disabled) and the back color turns to grey
i've got the following code, that works, but there is another value/text in combobox1 that when sellected it has to do the same.
The values are ziek, verlof, feestdag.
do i have to write this code 3 times, eachother with another value/text or is there a shortcut
Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "verlof" Then
Me.ComboBox2.Enabled = False
Me.ComboBox3.Enabled = False
Me.ComboBox4.Enabled = False
Me.ComboBox5.Enabled = False
Me.ComboBox6.Enabled = False
Me.ComboBox7.Enabled = False
Me.ComboBox8.Enabled = False
Me.ComboBox9.Enabled = False
Me.ComboBox10.Enabled = False
Me.ComboBox11.Enabled = False
Me.ComboBox12.Enabled = False
Me.ComboBox13.Enabled = False
Me.ComboBox14.Enabled = False
Me.ComboBox15.Enabled = False
Me.ComboBox16.Enabled = False
Me.ComboBox17.Enabled = False
Me.ComboBox2 = "-"
Me.ComboBox3 = "-"
Me.ComboBox4 = "-"
Me.ComboBox5 = "-"
Me.ComboBox6 = "-"
Me.ComboBox7 = "-"
Me.ComboBox8 = "-"
Me.ComboBox9 = "-"
Me.ComboBox10 = "-"
Me.ComboBox11 = "-"
Me.ComboBox12 = "-"
Me.ComboBox13 = "-"
Me.ComboBox14 = "-"
Me.ComboBox15 = "-"
Me.ComboBox16 = "-"
Me.ComboBox17 = "-"
Me.ComboBox2.BackColor = RGB(224, 224, 224)
Me.ComboBox3.BackColor = RGB(224, 224, 224)
Me.ComboBox4.BackColor = RGB(224, 224, 224)
Me.ComboBox5.BackColor = RGB(224, 224, 224)
Me.ComboBox6.BackColor = RGB(224, 224, 224)
Me.ComboBox7.BackColor = RGB(224, 224, 224)
Me.ComboBox8.BackColor = RGB(224, 224, 224)
Me.ComboBox9.BackColor = RGB(224, 224, 224)
Me.ComboBox10.BackColor = RGB(224, 224, 224)
Me.ComboBox11.BackColor = RGB(224, 224, 224)
Me.ComboBox12.BackColor = RGB(224, 224, 224)
Me.ComboBox13.BackColor = RGB(224, 224, 224)
Me.ComboBox14.BackColor = RGB(224, 224, 224)
Me.ComboBox15.BackColor = RGB(224, 224, 224)
Me.ComboBox16.BackColor = RGB(224, 224, 224)
Me.ComboBox17.BackColor = RGB(224, 224, 224)
End If
End Sub
I've got a userform combobox (dropdown) with about 6 items, but there are 3 value's in, that when sellected, the other userform comboboxes needs to be blocked (disabled) and the back color turns to grey
i've got the following code, that works, but there is another value/text in combobox1 that when sellected it has to do the same.
The values are ziek, verlof, feestdag.
do i have to write this code 3 times, eachother with another value/text or is there a shortcut
Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "verlof" Then
Me.ComboBox2.Enabled = False
Me.ComboBox3.Enabled = False
Me.ComboBox4.Enabled = False
Me.ComboBox5.Enabled = False
Me.ComboBox6.Enabled = False
Me.ComboBox7.Enabled = False
Me.ComboBox8.Enabled = False
Me.ComboBox9.Enabled = False
Me.ComboBox10.Enabled = False
Me.ComboBox11.Enabled = False
Me.ComboBox12.Enabled = False
Me.ComboBox13.Enabled = False
Me.ComboBox14.Enabled = False
Me.ComboBox15.Enabled = False
Me.ComboBox16.Enabled = False
Me.ComboBox17.Enabled = False
Me.ComboBox2 = "-"
Me.ComboBox3 = "-"
Me.ComboBox4 = "-"
Me.ComboBox5 = "-"
Me.ComboBox6 = "-"
Me.ComboBox7 = "-"
Me.ComboBox8 = "-"
Me.ComboBox9 = "-"
Me.ComboBox10 = "-"
Me.ComboBox11 = "-"
Me.ComboBox12 = "-"
Me.ComboBox13 = "-"
Me.ComboBox14 = "-"
Me.ComboBox15 = "-"
Me.ComboBox16 = "-"
Me.ComboBox17 = "-"
Me.ComboBox2.BackColor = RGB(224, 224, 224)
Me.ComboBox3.BackColor = RGB(224, 224, 224)
Me.ComboBox4.BackColor = RGB(224, 224, 224)
Me.ComboBox5.BackColor = RGB(224, 224, 224)
Me.ComboBox6.BackColor = RGB(224, 224, 224)
Me.ComboBox7.BackColor = RGB(224, 224, 224)
Me.ComboBox8.BackColor = RGB(224, 224, 224)
Me.ComboBox9.BackColor = RGB(224, 224, 224)
Me.ComboBox10.BackColor = RGB(224, 224, 224)
Me.ComboBox11.BackColor = RGB(224, 224, 224)
Me.ComboBox12.BackColor = RGB(224, 224, 224)
Me.ComboBox13.BackColor = RGB(224, 224, 224)
Me.ComboBox14.BackColor = RGB(224, 224, 224)
Me.ComboBox15.BackColor = RGB(224, 224, 224)
Me.ComboBox16.BackColor = RGB(224, 224, 224)
Me.ComboBox17.BackColor = RGB(224, 224, 224)
End If
End Sub