Extracting duplicate names that are similar in the first 3 words of the title.

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Welcome. I have a list of work section titles in column A, for example,
The database was installed on the last day.
Sometimes I write it like this: The The database was installed on the last
. This is just an example. What I'm looking for is a code or Formula to extract duplicate names that are similar in the first 3 words of the title.
 

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
One way would be to use a UDF to remove sequential duplicates.

Book2 (version 1).xlsb
AB
1BeforeAfter
2The The database was installed on the lastThe database was installed on the last
3The The The database was installed on the lastThe database was installed on the last
4The database database database was installed on the lastThe database was installed on the last
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=removedups(A2)


VBA Code:
Function RemoveDups(Title As String) As String
    Dim S As String, SA As Variant, I As Long
    
    SA = Split(Application.Trim(Replace(Title, Chr(160), " ")), " ")
    For I = 0 To UBound(SA) - 1
        If SA(I) = SA(I + 1) Then
            S = S & " "
        Else
            S = S & SA(I) & " "
        End If
    Next I
    S = Application.Trim(S & SA(UBound(SA)))
    RemoveDups = S
End Function
 
Upvote 0

Forum statistics

Threads
1,221,498
Messages
6,160,161
Members
451,627
Latest member
WORBY10

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