VBA: If CheckBox.Value = True Then ...
Solved
fannoche35
Posted messages
12
Status
Membre
-
fannoche35 Posted messages 12 Status Membre -
fannoche35 Posted messages 12 Status Membre -
Hello,
I am looking to create a macro that will display rows 96 to 167 if any of the 3 checkboxes are checked.
Here is the code I entered, but I get an error message saying that an object is required
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Private Sub CheckBox21_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Thank you in advance for your help!
I am looking to create a macro that will display rows 96 to 167 if any of the 3 checkboxes are checked.
Here is the code I entered, but I get an error message saying that an object is required
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Private Sub CheckBox21_Click()
If CheckBox1.Value = True Or CheckBox3.Value = True Or CheckBox21.Value = True Then
Rows("96:167").EntireRow.Hidden = False
Else
Rows("96:167").EntireRow.Hidden = True
End If
End Sub
Thank you in advance for your help!
2 réponses
Try this
The checkboxXX_Click events call the (same) procedure OK
Best regards
The checkboxXX_Click events call the (same) procedure OK
Option Explicit Sub ok() If CheckBox1 Then Rows(76).Hidden = False Else Rows(76).Hidden = True End If If CheckBox3 Then Rows(78).Hidden = False Else Rows(78).Hidden = True End If If CheckBox21 Then Rows(88).Hidden = False Else Rows(88).Hidden = True End If If (CheckBox1 Or CheckBox3 Or CheckBox21) = True Then Rows("96:167").Hidden = False Else Rows("96:167").Hidden = True End If End Sub Private Sub CheckBox1_Click() Call ok End Sub Private Sub CheckBox3_Click() Call ok End Sub Private Sub CheckBox21_Click() Call ok End Sub Best regards
Excellent