I have a set of data with different groups ("colors"). For each group (color), there are questions that apply to "categories" ("A", "B", "C", etc.). Each has a numerical score. I need to pick the highest scoring question for each category, for each group (color).
Example: Group "Blue" has 2 questions that apply to category "A". One has a score of 4, the other has a score of 2. The question with a score of 4 is the one that should be used.
This is simple enough, but there is an additional rule that makes everything more complicated: Some questions apply to multiple categories, but these questions can only be used for 1 category (or not used at all).
Because of this rule, there are several scenarios that come up, and as a result certain logic that needs to be applied:
Is there any sort of formula or VBA code that can do anything like this?
Thank you all!
Example (the last column is the one I'm trying to automate):
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Color[/TD]
[TD]Question[/TD]
[TD]Categories it can be used for[/TD]
[TD]Score[/TD]
[TD]Category to apply it to[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]blah blah[/TD]
[TD]A[/TD]
[TD]4[/TD]
[TD]Don't Use[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]xyz[/TD]
[TD]A;B[/TD]
[TD]5[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]gibberish[/TD]
[TD]C[/TD]
[TD]4[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]hello[/TD]
[TD]C;D[/TD]
[TD]5[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]lol[/TD]
[TD]B[/TD]
[TD]6[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD]ggdfklj[/TD]
[TD]A[/TD]
[TD]4[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD]blah blah[/TD]
[TD]B[/TD]
[TD]6[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD]xyz[/TD]
[TD]C[/TD]
[TD]4[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD]gibberish[/TD]
[TD]B;C[/TD]
[TD]3[/TD]
[TD]Don't Use[/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD]hello[/TD]
[TD]D[/TD]
[TD]1[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]ssasas[/TD]
[TD]A:B[/TD]
[TD]6[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]sdsdff[/TD]
[TD]B[/TD]
[TD]4[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]fffrrd[/TD]
[TD]C[/TD]
[TD]4[/TD]
[TD]Don't Use[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]blah[/TD]
[TD]D[/TD]
[TD]6[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]brrrr[/TD]
[TD]C;D[/TD]
[TD]8[/TD]
[TD]C[/TD]
[/TR]
</tbody>[/TABLE]
Example: Group "Blue" has 2 questions that apply to category "A". One has a score of 4, the other has a score of 2. The question with a score of 4 is the one that should be used.
This is simple enough, but there is an additional rule that makes everything more complicated: Some questions apply to multiple categories, but these questions can only be used for 1 category (or not used at all).
Because of this rule, there are several scenarios that come up, and as a result certain logic that needs to be applied:
- If a question applies to multiple categories and one of those categories has no other questions that apply to it, the question should be used for that category [Ex: if question 1 applies to categories A & B, and there are no other questions that apply to category A, question 1 should apply to category A. If neither category A nor category B have any other questions that apply to it, question 1 can be applied to either (but not both). It doesn't matter which one it's applied to.]
- If a question applies to multiple categories and each of those categories have other questions that apply to that category, the question that applies to multiple categories should be applied to lowest scoring category [Ex: "Question 4" applies to categories B & C and has a score of 7; "question 6" only applies to category B and has a score of 3. "Question 11" only applies to category C and has a score of 5. Since "question 6" scores worse than "question 11", "question 4" should be applied to category B. Note that if "question 4" had a score of 3 or lower, it would not be applied to either category
Is there any sort of formula or VBA code that can do anything like this?
Thank you all!
Example (the last column is the one I'm trying to automate):
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Color[/TD]
[TD]Question[/TD]
[TD]Categories it can be used for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