Display text with highest frequency in range

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
I have a range D2:D2500 with various names of clients. I am trying to figure out which one appears the most time.

I am able to figure out the occurrence of the repetition by using the function: =MODE(COUNTIF(D2:D2500,D2:D2500)) but I am unable to get the name to display.

Does anyone have any suggestions? A VBA solution would be preferred, but a function will work too.

Thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Perhaps something like

=INDEX(D:D, 10000*MOD(MAX(COUNTIF(D2:D2500,D2:D2500)+(ROW(D2:D2500)/10000)),1), 1)

which should be entered with Ctrl-Shift-Enter (Cmd+Return for Mac)
 
Upvote 0
That almost works, but it cuts off part of the data after the sixth character for some reason.
 
Upvote 0
Actually, I just figured out what the problem is, it always just shows the value in D1.
 
Upvote 0
You need to press Control+Shift+Enter, not just Enter

Also try,

=INDEX(D2:D2500,MATCH(MAX(COUNTIF(D2:D2500,D2:D2500)),COUNTIF(D2:D2500,D2:D2500),0))

Confirmed with Control+Shift+Enter, not just Enter.
 
Upvote 0
Haseeb,
I am using Ctrl+shift+enter for the array formula, but it is still not working. Your formula always shows the name on the top of the data.
 
Upvote 0
I have a range D2:D2500 with various names of clients. I am trying to figure out which one appears the most time.

I am able to figure out the occurrence of the repetition by using the function: =MODE(COUNTIF(D2:D2500,D2:D2500)) but I am unable to get the name to display.

Does anyone have any suggestions? A VBA solution would be preferred, but a function will work too.

Thanks

E1: #Most Freq#

E2, control+shift+enter, not just enter, and copy down:

If on 2007 or later...
Rich (BB code):
=IFERROR(INDEX($D$2:$D$11,MODE(IF(COUNTIF($D$2:$D$11,$D$2:$D$11)>1,
   IF(ISNA(MATCH($D$2:$D$11,$N$1:N1,0)),MATCH($D$2:$D$11,$D$2:$D$11,0))))),"")

Otherwise:
Rich (BB code):
=LOOKUP(REPT("z",255),CHOOSE({1,2},"",INDEX($D$2:$D$11,
   MODE(IF(COUNTIF($D$2:$D$11,$D$2:$D$11)>1,IF(ISNA(MATCH($D$2:$D$11,$E$1:E1,0)),
     MATCH($D$2:$D$11,$D$2:$D$11,0)))))))
 
Upvote 0
Thanks everybody who helped me. I finally got it working now.

It is amazing how complicated it is to get this working for text when a simple MODE function works for numbers.

Now, does anyone have a VBA solution as well?
 
Last edited:
Upvote 0
Thanks everybody who helped me. I finally got it working now.

It is amazing how complicated it is to get this working for text when a simple MODE function works for numbers.
It may be as easy as this.

Array entered**:

=INDEX(range,MODE(MATCH(range,range,0)))

That assumes there are no empty cells within the range and that there is at least one entry that has multiple instances (mode).

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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