Determine second most used text even if it only occurs once.

cspengel

Board Regular
Joined
Oct 29, 2022
Messages
173
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
There is always only going to be two different text strings. Both will never occur the same amount of times. Basically I just want to know which one occurs the least. The text may vary, so a countif or lookup is not an option as the names are not known, just the range of data. In example,

sam sam sam sam bill

least: bill

Thanks for any assistance.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Book1
ABCDEFGHIJ
1sam sam sam bill sambillsamsambillsambill
2bill sam sambill
3bill bill sam sam billsam
4george al al george algeorge
5al al george al george george georgeal
6
Sheet1
Cell Formulas
RangeFormula
B1:B5B1=LET(txt, A1:A5 & " ", lt, LEN(txt), f, TEXTBEFORE(txt," "), lf, LEN(f), s, TEXTBEFORE(SUBSTITUTE(txt, f & " ","")," "),ls, LEN(s), nf,(lt - LEN(SUBSTITUTE(txt, f & " ","")))/(LEN(f)+1), ns,(lt - LEN(SUBSTITUTE(txt, s & " ","")))/(LEN(s)+1), IF(nf>ns,s,f))
I1I1=LET(txt,TEXTJOIN(" ", 1, D1:G1) & " ", lt, LEN(txt), f, TEXTBEFORE(txt," "), lf, LEN(f), s, TEXTBEFORE(SUBSTITUTE(txt, f & " ","")," "),ls, LEN(s), nf,(lt - LEN(SUBSTITUTE(txt, f & " ","")))/(LEN(f)+1), ns,(lt - LEN(SUBSTITUTE(txt, s & " ","")))/(LEN(s)+1), IF(nf>ns,s,f))
Dynamic array formulas.
 
Upvote 0
Couple of other options.
Fluff.xlsm
ABCDEFG
1
2samsamsambillbillbill
3sam sam sam sam bill billbill
Data
Cell Formulas
RangeFormula
G2G2=LET(c,COUNTIF(A2:E2,A2:E2),TAKE(FILTER(A2:E2,c=MIN(c)),,1))
G3G3=LET(a,TEXTSPLIT(A3,," "),m,MMULT(--(a=TRANSPOSE(a)),SEQUENCE(ROWS(a),,,0)),TAKE(FILTER(a,m=MIN(m)),1))
 
Upvote 0
Solution
Thank you JGordon11 & Fluff! I went with the non-array, =LET(c,COUNTIF(A2:E2,A2:E2),TAKE(FILTER(A2:E2,c=MIN(c)),,1)) simply because I don't know how to add an array formula in VBA. Does just what I need.

 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,709
Members
449,464
Latest member
againofsoul

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