Find most frequent string

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,421
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to find the most frequent string in a range but with criteria.

I want to search the range E2:AH77 for the most common string that occurs but only in the rows where the value in column C matches "TEST". I have this, which works if I search a single column, (i.e. E2:E77), but gives me #N/A if I try to search the whole range, presumably because there are blank cells in that range too.

Excel Formula:
=INDEX(ISSUES!E2:E77,MODE(IF(ISSUES!C2:C77="TEST",IF(ISSUES!E2:E77<>"",MATCH(ISSUES!E2:E77,ISSUES!E2:E77,{0,0})))))

Can anyone help me move this forward please?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Your formula isn't working because MATCH does not work on a 2-D range. That is in fact the toughest part of this question. Here's my best stab at it:

Book1
ABCDEFGHIJKLMN
1Most common value
2xTEST
3TEST
4Most common valueTESTs
5xTESTxq
6TESTxq
7TESTxxs
8ValueCountTESTxyq
9s2TEST
10x8yx
11q3TESTx
12y6TESTyyyy
13  TESTy
14  TESTx
15  TESTx
16  TEST
17  
Sheet39
Cell Formulas
RangeFormula
A2A2=INDIRECT(TEXT(MOD(AGGREGATE(14,6,(COUNTIF(E2:AH77,E2:AH77)+ROW(E2:AH77)/100+COLUMN(E2:AH77)/10000)/(C2:C77="TEST")/(E2:AH77<>""),1),1)*10000,"R00C00"),0)
A5A5=INDEX(A9:A100,MATCH(MAX(B9:B100),B9:B100,0))
A9:A17A9=IFERROR(INDIRECT(TEXT(AGGREGATE(15,6,(ROW($E$2:$AH$77)*100+COLUMN($E$2:$AH$77))/($C$2:$C$77="TEST")/($E$2:$AH$77<>"")/(COUNTIF(A$8:A8,$E$2:$AH$77)=0),1),"R00C00"),0),"")
B9:B17B9=IF(A9="","",SUMPRODUCT(($E$2:$AH$77=A9)*($C$2:$C$77="TEST")))


The A2 formula was my first effort. It looks good at first, but then I realized that it will include some rows that do not have TEST in them.

The next attempt starts will a formula to find all the unique, acceptable values. The formula in A9:A18 does that, drag it down as needed. Then the B9 formula counts the number of valid matches for each value. Finally, the A5 formula finds the maximum count, and picks it out of the A9:Axxx range.

Not especially neat, but you can put the helper formulas out of sight somewhere.
 
Upvote 0
Thanks Eric - I'll have a play and see if I can use it.
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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