Count items return which occurs most

waveout

New Member
Joined
Apr 4, 2006
Messages
15
Using the following data (this list could be several thousand lines long):

Apple
Orange
Strawberry
Orange
Apple
Apple
Tomato

I would like to count and return the item that occurs the most (Apple) then the one that returns 2nd most (Orange). If item only occurs once then it can be ignored.

Results would look like this:
Apple
Orange
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
A pivot table is ideal for this.

If you prefer a formula solution, you'll need to do a couple of things first. Use the Advanced Filter to generate a list of unique items that will be pasted to a an adjacent column.

Once you have the list of unique values, use this formula:

=COUNTIF($A$1:$A$100,C1)

where cells A1 to A100 are your list of values, and C1 is the first unique value. You can adjust the cell ranges to your worksheet.

I would recommend the Pivot Table solution over the formula. But if you require additional help, just post back.
 
Upvote 0
Try this:

Excel Workbook
ABCD
1LISTFrequencyMax
2Apple3Apple
3Orange2Orange
4Strawberry1
5Orange
6Apple
7Apple
8Tomato1
Sheet1
 
Upvote 0
asad,
Thanks for the help. I was able to use your code and it worked well until I have two items that occur the same number of times. It just repeats the first one twice.

Orange
Apple
Strawberry
Apple
Apple
Orange
Banana
Orange
Apple
Strawberry
Strawberry
Banana

Had the following results
Apple
Orange
Orange
Banana

The second Orange should of been Strawberry. Is this possible?
 
Upvote 0
Your List in A2:A12, put this formula in B2 and drag down


Code:
=LOOKUP(REPT("Z",255),CHOOSE({1,2},"",
INDEX($A$2:$A$12,MODE(IF(COUNTIF($A$2:$A$12,$A$2:$A$12)>1,
IF(ISERROR(MATCH($A$2:$A$12,$B$1:B1,0)),MATCH($A$2:$A$12,$A$2:$A$12,0)))))))

This is an array formula, so you confirm with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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