ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How can delete the duplicate word from a string in cell in EXCEL (https://www.excelbanter.com/excel-discussion-misc-queries/88304-how-can-delete-duplicate-word-string-cell-excel.html)

Laxman A Patil

How can delete the duplicate word from a string in cell in EXCEL
 
How we can delete the duplicate word from a string from a particular cell in
EXCEL

Miguel Zapico

How can delete the duplicate word from a string in cell in EXCEL
 
You can use a custom formula, using the regular expression component from
vbscript (it should be installed in your computer by default)
Open the Visual Basic Editor (Alt+11), create a new module (menu Insert -
Module) and paste the following:

Function RemoveDup(str1)
Dim regEx
Set regEx = CreateObject("vbscript.regexp")
regEx.Global = False
regEx.Pattern = "\b(\w+)\b\s+\1"
regEx.IgnoreCase = True
RemoveDup = regEx.Replace(str1, "$1")
End Function

Then you can use this function in your workbook, just typing =RemoveDup(A1),
for example.
The formula will remove the first repeated word, for removing all repeated
words change the line with regEx.Global = False to regEx.Global = True.

Hope this helps,
Miguel.

"Laxman A Patil" wrote:

How we can delete the duplicate word from a string from a particular cell in
EXCEL



All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com