Find cells that contain repeated words within a string

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
677
Office Version
  1. 365
Platform
  1. MacOS
Hi,

Re the below screenshot, would anybody please be able to advise how to find and count cells in a particular column that contain repeated words. In this example, manually counting shows that the result should be 3. Cardiff parkrun, Newport parkrun and Sharpham Fields Road parkrun do not contain repeated words, the other 3 do. The words can be anywhere in the string, they don't have to be consecutive.

Screenshot 2021-12-06 at 19.07.51.png


I've tried a few things, but nothing is working.

Thanks in advance.

Olly.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You could use a helper column with
Excel Formula:
=LET(Txt," "&A2&" ",Qty,SEQUENCE((LEN(Txt)-LEN(SUBSTITUTE(Txt," ","")))-1),w,REPLACE(LEFT(Txt,FIND("~",SUBSTITUTE(Txt," ","~",Qty+1))-1),1,FIND("~",SUBSTITUTE(Txt," ","~",Qty)),""),--(ROWS(w)<>ROWS(UNIQUE(w))))
 
Upvote 0
Solution
You could use a helper column with
Excel Formula:
=LET(Txt," "&A2&" ",Qty,SEQUENCE((LEN(Txt)-LEN(SUBSTITUTE(Txt," ","")))-1),w,REPLACE(LEFT(Txt,FIND("~",SUBSTITUTE(Txt," ","~",Qty+1))-1),1,FIND("~",SUBSTITUTE(Txt," ","~",Qty)),""),--(ROWS(w)<>ROWS(UNIQUE(w))))
Thanks. That worked. I need to build this into my bigger, main spreadsheet and will check that it works in there. Will come back if any issues. Thanks again.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Hi, Fluff. A minor thing: is there a way to have it so if the result is negative it shows as blank, rather than 0? Thanks.
 
Upvote 0
You should never really mix text & numbers in a column, as it can cause problems.
 
Upvote 0
Hi again, Fluff. I am now incorporating the formula into my full spreadsheet and am struggling to get it to work. My range column is B, so changed from A to B in the formula. The helper column is now BG, rather than B. How would I amend it so that it works with this, please?

=LET(Txt," "&B2&" ",Qty,SEQUENCE((LEN(Txt)-LEN(SUBSTITUTE(Txt," ","")))-1),w,REPLACE(LEFT(Txt,FIND("~",SUBSTITUTE(Txt," ","~",Qty+1))-1),1,FIND("~",SUBSTITUTE(Txt," ","~",Qty)),""),r,--(ROWS(w)<>ROWS(UNIQUE(w))),IF(r=0,"",r))

Thanks.
 
Upvote 0
Here are some screenshots of the layout, if you struggle to open the file.

Event List, in column B:
Main List.jpg


Where I need the formula, in column BG:
Double-Barrelled.jpg


Thanks again.
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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