ARKA ARKAYA GELEN ÇİFT İSİMLERİ TEKE DÜŞÜRME

YUSUF44

Destek Ekibi
Destek Ekibi
Katılım
4 Ocak 2006
Mesajlar
12,073
Excel Vers. ve Dili
İş : Ofis 365 - Türkçe
Ev: Ofis 365 - Türkçe
Aşağıdaki makroyu dener misiniz?

PHP:
Sub tekle()
son = Cells(Rows.Count, "A").End(3).Row
For i = 2 To son
    veri = Split(Cells(i, "A"), " ")
    ad = ""
    For j = 1 To UBound(veri)
        If veri(j) = veri(0) Then
            For k = 0 To j - 1
                If ad = "" Then
                    ad = veri(k)
                Else
                    ad = ad & " " & veri(k)
                End If
            Next
            Cells(i, "B") = ad
            k = UBound(veri)
            j = UBound(veri)
        End If
    Next
    If Cells(i, "B") = "" Then Cells(i, "B") = Cells(i, "A")
Next
End Sub
 
Son düzenleme:
Katılım
21 Haziran 2021
Mesajlar
64
Excel Vers. ve Dili
türkçe
Altın Üyelik Bitiş Tarihi
20-07-2023
Aşağıdaki makroyu dener misiniz?

PHP:
Sub tekle()
son = Cells(Rows.Count, "A").End(3).Row
For i = 2 To son
    veri = Split(Cells(i, "A"), " ")
    ad = ""
    For j = 1 To UBound(veri)
        If veri(j) = veri(0) Then
            For k = 0 To j - 1
                If ad = "" Then
                    ad = veri(k)
                Else
                    ad = ad & " " & veri(k)
                End If
            Next
            Cells(i, "B") = ad
            k = UBound(veri)
            j = UBound(veri)
        End If
    Next
    If Cells(i, "B") = "" Then Cells(i, "B") = Cells(i, "A")
Next
End Sub
Harika oldu teşekkürler.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
42,160
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Bu da "RegExp" ile alternatif olsun..

Kullanıcı tanımlı fonksiyon..

=UNIQUE_WORDS(A2)

C++:
Option Explicit

Function UNIQUE_WORDS(My_Range As Range)
    Application.Volatile True
    With VBA.CreateObject("VBScript.RegExp")
        .Pattern = "^(.+)\s*\1$"
        .Global = True
        .MultiLine = True
        UNIQUE_WORDS = .Replace(My_Range.Value, "$1")
    End With
End Function
 

Ekli dosyalar

Üst