Archive of Mr Excel Message Board
We have to submit marks for coursework in our GCSE course (taken at 16 yrs old here in England)
The marks fall into four categories called P, O, A and E.
At least one of these marks must come from each Science i.e. Biology, Physics, Chemistry so an example might be
P O A E
Biology experiment: 5 5 3 3
Chemistry expt. 7 3
Physics expt. 4 4 4
Biology Experiment (2) 6 3
My problem is to get Excel to add up the best selection of marks given the rules above. In this case I would choose P7 (from Chemistry), O6 (from Physics), A4 from Physics and then because I have not yet had a contribution from Biology I have to choose the E3 rather than the E4.
I can do this by eye easily enough but when there are a hundred students each with five or six pieces of coursework it is easy to make mistakes.
I know about using functions such as Max() and Sum() and I am beginning to be familiar with array formulae but I know nothing about VBA so a solution without it would be much appreciated. However, if a macro is the only way then I'll happily start learning about them.
This would save me loads of time so anything you could suggest would be great



The numbers in my example should read:
Bio Expt: (P)5 (O)5 (A)3 (E)3
Chem Expt: (P)7 (O)3 (A)- (E)- not every piece of coursework is awarded a mark for all four skills.
Phys Expt: (P)4 (O)- (A)4 (E)4
Phys Expt 2: (P)- (O)6 (A)3 (E)-
I would love to take (P)7 (O)6 (A)4 (E)4 for this student but I can't because that would not include any Biology mark, so I have to sacrifice either the (O)6 or the (E)4 from the Physics experiments in favour of the lower mark from Biology. No, I can't automatically add up the highest in each skill and yes, I'm afraid fuzzy logic is probably the name of the game!
Doing this automatically is way beyond me, and may be beyond Excel but if any of you find a solution or at least tell me that no such solution is possible then at least I can stop worrying about it and go back to teaching. Thanks again. Pete


(I'm copying this straight from a solver example "Transportation problem", applying to your case)
In C1:F1 put {"P","O","A","E"}
In A2:A5 put {"Bio Expt";"Chem Expt";"Phys Expt";"Phys Expt 2"}
Now, in C2:F5 fill in 1 (One's).
In B2:B5 put the formulas =SUM(C2:F2) and fill down accordingly.
In C6:F6 put =SUM(C2:C5) and fill right.
In C8:F8 fill with 1's again (Only ONE letter allowed, that is, one resut for P, one for 0, one for A, and one for E).
In A10:A13 put {"Bio Expt";"Chem Expt";"Phys Expt";"Phys Expt 2"} this is just for identification.
In B10:B13 fil with 1's (One result per Subject)
In C10:G13 fill the results for each student. {5,5,3,3;7,3,0,0;4,0,4,4;0,6,3,0}
In C15:F15 put this formula =SUMPRODUCT(C2:C5,C10:C13) and fill right
In B15 put =SUM(C15:F15)
Now, go to Tools, Solver, finally. Object Cell is B15, value is MAXIMUM, changing cells C2:F5.
Constraints:
B2:B5<=B10:B13
C2:F5>=0
C6:F6>=C8:F8
Click SOLVE, and BINGO, you have the combinations that you need...
Hope that helps !
Juan Pablo

The optimum solution for this case would be:
