Most Frequent Letter in a Column of Four Different Letters

valmir

Board Regular
Joined
Feb 10, 2021
Messages
239
Office Version
  1. 365
Platform
  1. Windows
Hello everyone:
I'm using this formula:
=IF(COUNTIF(G3:G14,"b")>MAX(COUNTIF(G3:G14,"c"),COUNTIF(G3:G14,"q")),"b",IF(COUNTIF(G3:G14,"c")>COUNTIF(G3:G14,"q"),"c","q"))
that I found on this post Here
However this formula works perfectly but only for three letters, not four as I need.
Can anyone help me?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Of course it doesn't because the formula only involves "b", "c", and "q" and there's no fourth letter involved.
Say, the fourth letter is "a". Then this should work:
Excel Formula:
=IF(COUNTIF(G3:G14,"b")>MAX(COUNTIF(G3:G14,"c"),COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"b",IF(COUNTIF(G3:G14,"c")>MAX(COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"c",IF(COUNTIF(G3:G14,"q")>COUNTIF(G3:G14,"a"), "q", "a"))
 
Upvote 0
Of course it doesn't because the formula only involves "b", "c", and "q" and there's no fourth letter involved.
Say, the fourth letter is "a". Then this should work:
Excel Formula:
=IF(COUNTIF(G3:G14,"b")>MAX(COUNTIF(G3:G14,"c"),COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"b",IF(COUNTIF(G3:G14,"c")>MAX(COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"c",IF(COUNTIF(G3:G14,"q")>COUNTIF(G3:G14,"a"), "q", "a"))
Thanks a lot. It works! Just one more thing. If there is no match it will return an "a" value, any way to prevent that, like returning an empty cell in case of no match?
 
Upvote 0
How about
Excel Formula:
=IFNA(INDEX(G3:G14,MODE(IF(G3:G14<>"",MATCH(G3:G14,G3:G14,0)))),"")
This needs to be confirmed with Ctrl Shift Enter, rather than just Enter.
 
Upvote 0
If there is no match it will return an "a" value, any way to prevent that, like returning an empty cell in case of no match?
Try:
Excel Formula:
=IF(COUNTIF(G3:G14,"b")>MAX(COUNTIF(G3:G14,"c"),COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"b",IF(COUNTIF(G3:G14,"c")>MAX(COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"c",IF(COUNTIF(G3:G14,"q")>COUNTIF(G3:G14,"a"), "q",IF(COUNTIF(G3:G14,"a")>0,"a",""))
 
Upvote 0
Solution
Try:
Excel Formula:
=IF(COUNTIF(G3:G14,"b")>MAX(COUNTIF(G3:G14,"c"),COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"b",IF(COUNTIF(G3:G14,"c")>MAX(COUNTIF(G3:G14,"q"),COUNTIF(G3:G14,"a")),"c",IF(COUNTIF(G3:G14,"q")>COUNTIF(G3:G14,"a"), "q",IF(COUNTIF(G3:G14,"a")>0,"a",""))
Exactly! Works perfectly! Thank you so much for your help, sir!
 
Upvote 0
Glad to know it helped. But Fluff's approach in #4 is more elegant, if you choose not to stick to IF formulas.
Didn't work for me. was returning a "#NAME?" error. Maybe wrong Office version? I don't know.
 
Upvote 0
Oops IFNA didn't appear until 2013.
If you change that to IFERROR it should work.
 
Upvote 0
Didn't work for me. was returning a "#NAME?" error. Maybe wrong Office version? I don't know.
IFNA works only for Excel 2013 or later. How about:
Excel Formula:
=IFERROR(INDEX(G3:G14,MODE(IF(G3:G14<>"",MATCH(G3:G14,G3:G14,0)))),"")
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,357
Members
449,155
Latest member
ravioli44

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