mode for text-strings ?

alcorjr

Active Member
Joined
Dec 29, 2002
Messages
416
Hi everybody,

Is there a function that can return the most frequently appearing text string from a range?

Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
This formula

=INDEX(Rng,MATCH(MAX(COUNTIF(Rng,Rng)),COUNTIF(Rng,Rng),0))

array entered (That is, with Control Shift Enter, not just Enter), will return the (first) most common string in the range Rng
 
Upvote 0
To Juan Pablo:
Let's say that in a row ( Range a) I have:
12.5x 6x 3xy 5x 3xy 8y 3xy
I'm lookig for something of the sort

= mode(Range a)
In this case it shoud return "3xy"

That is, that it would function with texts in the same way that the MODE function works with values
 
Upvote 0
To Juan Pablo:
I'm not sure if I understand your formula;
if the array I'm analyzing is A5:A20, I should apply it like this?
=INDEX(A5:A20,MATCH(MAX(COUNTIF(A5:A20,Rng)),COUNTIF(A5:A20,Rng),0))
But then the "Rng" that appears in the parenteses after the coma in the COUNTIF, should'nt be a condtion?

I'm a bit lost. Explain, please
 
Upvote 0
If yuo range is A5:A20, you have two choices:

1) Change, in my formula all instances of Rng with A5:A20

2) Select A5:A20, go to the name box (Left of the formula bar), type Rng in there and press Enter.

And the COUNTIF uses ALL cells in Rng, that's why is an array formula, because it "loops" through each of them.
 
Upvote 0
To Juan Pablo: I tried using your formula:
INDEX(Rng,MATCH(MAX(COUNTIF(Rng,Rng)),COUNTIF(Rng,Rng),0))
and it returns #N/A
although in the step-by step window(click on "fx") I see that is giving the correct result. What am I doing wrong?
Thanks and forgive the clumsiness
 
Upvote 0
This worked REALLY well - though it took me a while to figure out why most of my rows were returning a blank result... til I realized that for many of my rows I had "" values and I wanted to discount those.

Is there a way to apply this code to a range where only populated cells are counted? Or... is there a way other than assigning "" to a cell to force it to be empty?

THANK YOU, I find your suggestions very helpful!
 
Upvote 0

Forum statistics

Threads
1,224,112
Messages
6,176,431
Members
452,728
Latest member
mihael546

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