white_flag
12-21-2009, 08:32 AM
Hello,
I have the following code and I like to make it shorter, if this is possible. I mean less instruction (the same effect). in the "if" statement.
ex. IF <condition1, condition2, condition3 etc ...> AND <condition1, condition2, condition3 etc ...> THEN (instruction)
Select Case Range("$J$46").Value
Case Is = "AF"
If Range("$D$44").Value = 34 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 13 Then
Range("E58") = 0
Else
Range("E59") = formulaText
End If
Case Is = "Glass"
If Range("$D$44").Value >= 168 And Range("$E$44").Value = 30 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 27 And Range("$E$44").Value = 80 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 48 And Range("$E$44").Value = 90 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 48 And Range("$E$44").Value = 100 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 34 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 30 Then
Range("E58") = 0
Else
Range("E58") = formulaText
End If
Case Else
If Range("$D$44").Value = 34 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 30 Then
Range("E58") = 0
Else
Range("E59") = formulaText
End If
End Select
thank you
I have the following code and I like to make it shorter, if this is possible. I mean less instruction (the same effect). in the "if" statement.
ex. IF <condition1, condition2, condition3 etc ...> AND <condition1, condition2, condition3 etc ...> THEN (instruction)
Select Case Range("$J$46").Value
Case Is = "AF"
If Range("$D$44").Value = 34 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 9 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 13 Then
Range("E58") = 0
Else
Range("E59") = formulaText
End If
Case Is = "Glass"
If Range("$D$44").Value >= 168 And Range("$E$44").Value = 30 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 27 And Range("$E$44").Value = 80 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 48 And Range("$E$44").Value = 90 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 48 And Range("$E$44").Value = 100 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 34 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 30 Then
Range("E58") = 0
Else
Range("E58") = formulaText
End If
Case Else
If Range("$D$44").Value = 34 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 42 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value = 48 And Range("$E$44").Value = 25 Then
Range("E58") = 0
ElseIf Range("$D$44").Value <= 34 And Range("$E$44").Value = 30 Then
Range("E58") = 0
Else
Range("E59") = formulaText
End If
End Select
thank you