Hi guys,
I am working on a project where the user can decide, through some CheckBoxes and ComboBoxes placed on a Worksheet, to apply a multilevel sorting to a table placed on the same Sheet.
The code I wrote checks if each checkbox is selected and applies formatting rules in both cases. This code works out perfectly.
What I would like to achieve is to let the user select each Checkbox from the Level 2 till the end only if all the previous ones are checked. In case they are not, a message should inform the user that he made a mistake.
I am not able to write an IF statement in VBA that checks more than one condition at the same time before ELSE instruction (I tried also with SELECT CASE...CASE but I have the same difficulty).
Would you please help me?
Thanks a lot
Mark
I am working on a project where the user can decide, through some CheckBoxes and ComboBoxes placed on a Worksheet, to apply a multilevel sorting to a table placed on the same Sheet.
The code I wrote checks if each checkbox is selected and applies formatting rules in both cases. This code works out perfectly.
VBA Code:
Private Sub CheckBox1_Click()
Application.ScreenUpdating = False
If CheckBox1 Then
Me.ComboBox1.Enabled = True
Me.ComboBox1.BackColor = &HC0FFFF
Me.ComboBox5.Enabled = True
Me.ComboBox5.BackColor = &HC0FFFF
Else
Me.ComboBox1.Enabled = False
Me.ComboBox1.Value = ""
Me.ComboBox1.BackColor = &HE0E0E0
Me.ComboBox5.Enabled = False
Me.ComboBox5.Value = ""
Me.ComboBox5.BackColor = &HE0E0E0
End If
Application.ScreenUpdating = True
End Sub
Private Sub CheckBox2_Click()
Application.ScreenUpdating = False
If CheckBox2 Then
Me.ComboBox2.Enabled = True
Me.ComboBox2.BackColor = &HC0FFFF
Me.ComboBox6.Enabled = True
Me.ComboBox6.BackColor = &HC0FFFF
Else
Me.ComboBox2.Enabled = False
Me.ComboBox2.Value = ""
Me.ComboBox2.BackColor = &HE0E0E0
Me.ComboBox6.Enabled = False
Me.ComboBox6.Value = ""
Me.ComboBox6.BackColor = &HE0E0E0
End If
Application.ScreenUpdating = True
End Sub
Private Sub CheckBox3_Click()
Application.ScreenUpdating = False
If CheckBox3 Then
Me.ComboBox3.Enabled = True
Me.ComboBox3.BackColor = &HC0FFFF
Me.ComboBox8.Enabled = True
Me.ComboBox8.BackColor = &HC0FFFF
Else
Me.ComboBox3.Enabled = False
Me.ComboBox3.Value = ""
Me.ComboBox3.BackColor = &HE0E0E0
Me.ComboBox8.Enabled = False
Me.ComboBox8.Value = ""
Me.ComboBox8.BackColor = &HE0E0E0
End If
Application.ScreenUpdating = True
End Sub
Private Sub CheckBox4_Click()
Application.ScreenUpdating = False
If CheckBox4 Then
Me.ComboBox4.Enabled = True
Me.ComboBox4.BackColor = &HC0FFFF
Me.ComboBox7.Enabled = True
Me.ComboBox7.BackColor = &HC0FFFF
Else
Me.ComboBox4.Enabled = False
Me.ComboBox4.Value = ""
Me.ComboBox4.BackColor = &HE0E0E0
Me.ComboBox7.Enabled = False
Me.ComboBox7.Value = ""
Me.ComboBox7.BackColor = &HE0E0E0
End If
Application.ScreenUpdating = True
End Sub
[ATTACH type="full"]62751[/ATTACH]
What I would like to achieve is to let the user select each Checkbox from the Level 2 till the end only if all the previous ones are checked. In case they are not, a message should inform the user that he made a mistake.
I am not able to write an IF statement in VBA that checks more than one condition at the same time before ELSE instruction (I tried also with SELECT CASE...CASE but I have the same difficulty).
Would you please help me?
Thanks a lot
Mark