Hi All,
Please note I'm still relatively new to VBA and have limited knowledge.
Please see example of data below:
I'm trying to write code to determine what RESULTS would be based on the possible combinations between columns A-E, thus causes my issue of too many ELSEIF statements . Is there a way to do this more efficiently and not have to write out every single combination?
My conditions are:
- MS has be below 35 else it is considered a fail
- If any columns between A-E are between 0 to 30 then it would be considered positive for that specific column and thus transcribed into Results
Below is an example of my code just for these possible outcomes in the dataset above.
Thanks,
Ed
Please note I'm still relatively new to VBA and have limited knowledge.
Please see example of data below:
I'm trying to write code to determine what RESULTS would be based on the possible combinations between columns A-E, thus causes my issue of too many ELSEIF statements . Is there a way to do this more efficiently and not have to write out every single combination?
My conditions are:
- MS has be below 35 else it is considered a fail
- If any columns between A-E are between 0 to 30 then it would be considered positive for that specific column and thus transcribed into Results
Below is an example of my code just for these possible outcomes in the dataset above.
VBA Code:
For J = 2 To 8
P = Cells(J, "A").Value
M = Cells(J, "B").Value
K = Cells(J, "C").Value
R = Cells(J, "D").Value
B = Cells(J, "E").Value
Ms = Cells(J, "F").Value
If _
Ms > 38 Then
Cells(J, "G").Value = "Fail"
ElseIf _
P < 35 And _
M < 35 And _
K < 35 And _
R < 35 And _
B < 35 Then _
Cells(J, "G").Value = "P M K R B"
ElseIf _
M < 35 And _
K < 35 And _
R < 35 And _
B < 35 Then _
Cells(J, "G").Value = "M K R B"
ElseIf _
K < 35 And _
R < 35 And _
B < 35 Then _
Cells(J, "G").Value = "K R B"
ElseIf _
R < 35 And _
B < 35 Then _
Cells(J, "G").Value = "R B"
ElseIf _
B < 35 Then _
Cells(J, "G").Value = "B"
End If
Next J
Thanks,
Ed