• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

listbox'dan lisbox'a benzersiz veri aktarma

  • Konbuyu başlatan Konbuyu başlatan bebar
  • Başlangıç tarihi Başlangıç tarihi
Katılım
12 Kasım 2014
Mesajlar
255
Excel Vers. ve Dili
2013
merhaba

lb2 den lb1'ye veri aktarırken lb2 de seçili olan değer lb1de var ise aktarmasın istiyorum, aşağıdaki gibi bir kod oluşturdum fakat çalışmıyor. Yardımcı olursanız memnun olurum.

multiselect kullanıyorum

Kod:
 Özel Alt KomutDüğmesi1_Click ()
Tamsayı Olarak Dim I
Dim s1 Çalışma Sayfası Olarak
Set s1 = Sayfalar ("Sayfa1")
    otur = 18
    I = 1 için ListBox2.ListCount için - 1
        ListBox2.Selected (I) = Doğru ise
            K = 1 için ListBox1.ListCount - 1
             Eğer ListBox2.List (I) <> ListBox1.List (k) ise
                oturdu = oturdu + 1
                Hücreler (oturdu, "BE") = ListBox2.List (I)
                ListBox1.AddItem ListBox2.List (I)
            Bittiğinde
            Sonraki k
        Bittiğinde
    Sıradaki ben
Bitiş Alt [[KOD]
 
Son düzenleme:
Kod:
    If ListBox1.ListCount > 0 Then
        For i = 0 To ListBox1.ListCount - 1
            If ListBox1.List(i, 0) = ListBox2.Value Then bulundu = True: Exit For
        Next i
    End If
    If bulundu = False Then ListBox1.AddItem ListBox2.Value
 
Hocam Teşekkür ederim ama hata veriyor.
multiselect kullanıyorum belki ondan olabilir
 
Kod:
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) = True Then
            bulundu = False
            If ListBox1.ListCount > 0 Then
                For ii = 0 To ListBox1.ListCount - 1
                    If ListBox1.List(ii) = ListBox2.List(i) Then bulundu = True: Exit For
                Next ii
            End If
            If bulundu = False Then ListBox1.AddItem ListBox2.List(i)
        End If
    Next i
 
Hocam Çok teşkkür ederim büyük faydası oldu
 
Geri
Üst