Counting occurrences when the words can fit multiple meanings

claytont454

New Member
Joined
Feb 28, 2013
Messages
8
Hi folks, I've been solving this so far by doing lots of steps and thought someone might have a better idea.
My real application is counting vaccinations that are given in different combinations, but to make this shorter, I'll pretend that the people are students in a painting class that ran for 3 sessions. Each student can use red, blue, or yellow each day, and if they use green or orange, those count as 1 each of the primary colors (green=1 blue + 1 yellow, orange=1 red + 1 yellow). Here is their color usage, followed by the results that I'm calculating manually.

ABCDE
1NameColor usedSession1Session2Session3
2BillyRed1
3BillyOrange1
4BillyBlue111
5SallyPurple1
6SallyBlue1
7GinaGreen11
8FredYellow11
9FredOrange1

<colgroup><col><col><col><col span="3"></colgroup><tbody>
</tbody>

How can I use Excel to get the following table, hopefully with little or no programming?
Thanks in advance for your ideas!
Results: How many of each color did each student use?
ABCD
1RedYellowBlue
2Billy213
3Sally102
4Gina011
5Fred120

<colgroup><col span="5"></colgroup><tbody>
</tbody>
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I saw Billy use one red, one orange, three blue, and no yellow. Why are there two red and one yellow in the result table?
 
Last edited:
Upvote 0
For my understanding: didn't Gina use 2 units of yellow and 2 units of blue instead of 1 each? And didn't Fred use 3 units of yellow instead of 2?
 
Upvote 0
First I added three columns next to the main table for 'red', 'yellow' and 'blue'. Then I added a small table below that, telling me which colors green, orange and purple are made of. Finally I placed the table with the totals in the left lower corner:

NameColor usedSession1Session2Session3 redyellowblue
Billyred1100
BillyOrange1110
BillyBlue111003
SallyPurple1101
SallyBlue1001
GinaGreen11022
FredYellow11020
FredOrange1110
NameRedYellowBlue
Billy213greenblueyellow
Sally102orangeredyellow
Gina022purpleredblue
Fred130

<tbody>
</tbody>


Then I added the following formula in cell F2 which is the first cell in the 'red' column:
Code:
=IF(OR($B2=F$1,NOT(ISNA(HLOOKUP(F$1,INDEX($G$13:$H$15,MATCH($B2,$F$13:$F$15,0),0),1,0)))),SUM($C2:$E2),0)
Then I copied this formula to all other cells below 'red ....blue'.

Finally, I added the following formula in the cell of the totals table at the intersection of 'Billy' and 'red':
Code:
=SUMIF($A$2:$A$9,$A13,$F$2:$F$9)
and copied this one in all other cells for Sally, Gina and Fred.

I hope this will work for you.

Btw: how can I add neat images of spreadfsheets to posts?
 
Last edited:
Upvote 0
To add borders to a table, you click your mouse inside one of the cells then look for an icon at the top of your editing window.
One of the icons is for "Table properties", and you can change the Borders to show the whole grid or just the border.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,544
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top