how to remove dupliucate strings within a cell

zakynthos

Board Regular
Joined
Mar 28, 2011
Messages
169
I would like to be able to remove any duplicate strings within individual cells in column D

Example:


IN D2 PM4567, PM1000, PM1000

IN D3 PM9999, PM3200, PM3200 etc

To return:


IN D2 PM4567, PM1000

IN D3 PM9999, PM3200

Many thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try using this function
Code:
'below is a unique string concatenation
Function StringConcat(str_delim As String, ParamArray rng_txt() As Variant) As String
Dim oDic As Object, v, c_i As Long, n As Long, i As Long, cell As Range
Set oDic = CreateObject("Scripting.Dictionary")
n = 1
For c_i = LBound(rng_txt) To UBound(rng_txt) Step 1
    If TypeName(rng_txt(c_i)) = "Range" Then
        For Each cell In rng_txt(c_i)
            v = Split(Trim(cell.Value), str_delim)
            For i = LBound(v) To UBound(v)
                v(i) = Trim(v(i))
                If Not oDic.exists(v(i)) Then
                    n = n + 1
                    oDic.Add v(i), n
                End If
            Next i
        Next cell
    End If
Next c_i
StringConcat = Join(oDic.keys, str_delim)
Set oDic = Nothing
End Function
 
Upvote 0

Forum statistics

Threads
1,207,090
Messages
6,076,520
Members
446,211
Latest member
b306750

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