So I'm looking to do something in VBA that has multiple conditions..
First set of conditions..
So essentially, If C14:C17 has either 2,3,4,5
AND D14:D17 Essentially has data...
AND E14:E17 Also has data...
Second Set of Conditions
K14 must equal Cutwidth1butt2
AND J14 <= D13
My issue is that this code is running right through.. It's always passing. Even when K14 doesn't equal the cutwidth.. As far as what I've experimented with previously, multiple "And" conditions work. But when I tried to mix "Or" conditions, it seems to behave differently? I'm a beginner in VBA so be easy on me! haha.
Full Code
HTML:
Dim Cutwidth1butt2 As Integer
Cutwidth1butt2 = [M7].Value - [E14].Value
Code:
If [C14] = "2" Or [C15] = "3" Or [C16] = "4" Or [C17] = "5" And [D14] <> "" Or [D15] <> "" Or [D16] <> "" Or [D17] <> "" And [E14] <> "" Or [E15] <> "" Or [E16] <> "" Or [E17] <> "" And [K14] = Cutwidth1butt2 And [J14] <= [D13] Then
First set of conditions..
So essentially, If C14:C17 has either 2,3,4,5
AND D14:D17 Essentially has data...
AND E14:E17 Also has data...
Second Set of Conditions
K14 must equal Cutwidth1butt2
AND J14 <= D13
My issue is that this code is running right through.. It's always passing. Even when K14 doesn't equal the cutwidth.. As far as what I've experimented with previously, multiple "And" conditions work. But when I tried to mix "Or" conditions, it seems to behave differently? I'm a beginner in VBA so be easy on me! haha.
Full Code
Code:
'[IF THERE IS ANY TAIL ATTACHED TO THE SECTION] AND CUT WIDTH IS THE SAME WIDTH AS THE "CUTWIDTH"
If [C14] = "2" Or [C15] = "3" Or [C16] = "4" Or [C17] = "5" And [D14] <> "" Or [D15] <> "" Or [D16] <> "" Or [D17] <> "" And [E14] <> "" Or [E15] <> "" Or [E16] <> "" Or [E17] <> "" And [K14] = Cutwidth1butt2 And [J14] <= [D13] Then
[D13].Value = [D13] - [J14]
[D14].Value = [D14] + [J14]
'Disable Button
MakeCut2.Enabled = False
'Has cut been made?
[M14].Value = "Yes"
MsgBox Test
End If
Last edited: