• 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 ...
 

jolivanes

Member
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
 
Top