Sub Crons()
Dim s1 As Worksheet, s2 As Worksheet
Dim check1 As Boolean, check5 As Boolean, check10 As Boolean, flow As Boolean, speed As Boolean, motor_power As Boolean
Set s1 = ThisWorkbook.Worksheets(1)
Set s2 = ThisWorkbook.Worksheets(2)
check1 = s2.CHECKBOXES("Check Box 1").Value = xlOn
check5 = s2.CHECKBOXES("Check Box 5").Value = xlOn
check10 = s2.CHECKBOXES("Check Box 10").Value = xlOn
flow = s1.Range("B26").Value = "Flow(from fill level)"
speed = s1.Range("B24").Value = "Speed"
motor_power = s1.Range("B25").Value = "Motor Power"
If check1 Or _
((check10 Or check5) Or _
(flow Or speed) Or _
(motor_power)) Then
s1.Range("B30").Value = "Activate anomaly detection" And _
s1.Range("B31").Value = "Activate Operating hour" And _
s1.Range("B32").Value = "Activate cycle time"
Else
s1.Range("B30").Value = vbNullString And _
s1.Range("B31").Value = vbNullString And _
s1.Range("B32").Value = vbNullString
End If
End Sub
>Solution :
Just don’t use AND!
If check1 Or _
((check10 Or check5) Or _
(flow Or speed) Or _
(motor_power)) Then
s1.Range("B30").Value = "Activate anomaly detection"
s1.Range("B31").Value = "Activate Operating hour"
s1.Range("B32").Value = "Activate cycle time"
Else
s1.Range("B30").Value = vbNullString
s1.Range("B31").Value = vbNullString
s1.Range("B32").Value = vbNullString
End If