remove duplicate values from a excel cell

Microsoft Excel is used by everyone in the world for all data related things, some time we have duplicate cell contents in rows or in columns.

To remove these duplicate values from the sheet we already have a feature “Remove Duplicates” in latest version of the excel application. But if we have some duplicate values in a single cell then this feature will not work, we need some another alternative, either we delete manually or can create a Macro / Addins / Custom Function.

Manual process will not help because it required lot of concentration,? To resolved that I have created a Addins which we can integrate in excel application and access this custom function like other we generally used.

Steps to create addins:
– Go to View – > Macro
– Define Name “RemoveDuplicatesFromCell” and click on create Button
– Add the following code at Module1 file
– Save the file as RemoveDuplicatesFromCell.xla
[vbnet]
Function RemoveDuplicatesFromCell(txt As String, Optional delim As String = ” “) As String
Dim x
With CreateObject(“Scripting.Dictionary”)
.CompareMode = vbTextCompare
For Each x In Split(txt, delim)
If Trim(x) <> “” And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
Next
If .Count > 0 Then RemoveDuplicatesFromCell= Join(.keys, delim)
End With
End Function
[/vbnet]
 


Posted

in

, , ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *