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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,348
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

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
That almost works, but it cuts off part of the data after the sixth character for some reason.
 
Upvote 0

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
Actually, I just figured out what the problem is, it always just shows the value in D1.
 
Upvote 0

Haseeb Avarakkan

Well-known Member
Joined
Sep 28, 2010
Messages
902
Office Version
  1. 365
Platform
  1. Windows
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

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
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

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
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

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
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

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623
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,191,187
Messages
5,985,194
Members
439,947
Latest member
fabiannic

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
Top