count occurrences of values in a column

englishrob

New Member
Joined
May 17, 2010
Messages
22
What would be the best way to count the number of occurrences of each value in a column?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I tried to create a pivot table, but could only get it to work if I placed a 1 in the adjacent cell next to each value, i.e. another column. I can figure it out using procedural style code in VBA (test for change of value in cell below) but guess there must be a better way using ranges. I’m ok with VBA but not done much on Pivot Tables.<o:p></o:p>
<o:p></o:p>
Sample data:<o:p></o:p>
<o:p></o:p>
Sun<o:p></o:p>
Sun<o:p></o:p>
Sun<o:p></o:p>
Sun<o:p></o:p>
<o:p></o:p>
To show 4 next to the last Sun<o:p></o:p>
<o:p></o:p>
Mon<o:p></o:p>
Mon<o:p></o:p>
<o:p></o:p>
To show 2 next to the last Mon<o:p></o:p>
<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
Tue<o:p></o:p>
<o:p></o:p>
To show 7 next to the last Tue<o:p></o:p>
<o:p></o:p>
Thanks<o:p></o:p>
<o:p></o:p>
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can use a Pivot to give a Day with Count by setting the Day field as both Row & Data Field (the latter should default to Count by default).
 
Upvote 0
With a pivot table you'd just drag the day column into both row labels and value fields.
Excel Workbook
A
1Day
2Sun
3Sun
4Sun
5Sun
6Mon
7Mon
8Tue
9Tue
10Tue
11Tue
12Tue
13Tue
14Tue
Sheet4
Excel 2007
Excel Workbook
AB
3Row LabelsCount of Day
4Mon2
5Tue7
6Sun4
7Grand Total13
Sheet5
Excel 2007
 
Upvote 0
Try this - formula in B1 copied down

Excel Workbook
AB
1Sun 
2Sun
3Sun
4Sun4
5Mon
6Mon2
7Tue
8Tue
9Tue
10Tue
11Tue
12Tue
13Tue7
Sheet2
 
Upvote 0
Assuming we are talking about Column A, then this formula seems to work...

=IF(COUNTIF(A$1:A1,A1)=COUNTIF(A:A,A1),COUNTIF(A:A,A1),"")

Note: This formula will work even if the data is not sorted by the contents of Column A.
 
Upvote 0

Forum statistics

Threads
1,224,569
Messages
6,179,605
Members
452,928
Latest member
VinceG

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