• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Removing a repeated words

nmkhan3010

New Member
hi,

i need a macro for removing a immediate duplicate words in a documents.

example :

Input: financial income income
Output: financial income

Input: unit: unit: INR
Output: unit: INR

Input : gain gain from sales
Output : gain from sales

In the above cases immediate repeated words removed manully like income, unit: & gain
If there is no same repeated word it remains constant and it has not to be changed in anywhere.
Ex: income from sales, unit: INR, gain from investments replaced above words will not be reflect anywhere in a doc because it is having a single word income, unit:, gain.

Wildcard Find/Replace : Please check and make this is in macro... Wild card is not working, please check and review once.
Find = (<*>?@)\1
Replace = \1


please do the needful ...
 
nmkhan3010
Maybe I missed Your document,
but this should do something same with parts of texts.
Remember to read instructions before use (and have backups).
 

Attachments

  • PleaseDoTheNeedful.xlsb
    16.6 KB · Views: 11
Or maybe something like this, starting at A2.
Code:
Sub Maybe()
Dim c As Range, i As Long, sp
    For Each c In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
    sp = Split(c, " ")
        For i = LBound(sp) To UBound(sp) - 1
            If sp(i) = sp(i + 1) Then sp(i) = "": Exit For
        Next i
        c.Value = Trim(Join(sp, " "))
    Next c
End Sub
 
Hi, Thanks for replying i need this macro for a word document, in a document am haiving multiple strings.

For reference please see the attachment.

Thnaks for the needful....
 

Attachments

  • TEST.docx
    53.5 KB · Views: 1
I'm sorry, I thought I was answering in an Excel Forum.
I do not know anything about Word macros but I have read that they are similar.
 
Back
Top