İki Listbox Arası Veri Aktarma / Var olanı tekrar aktarmadan

walabi

Altın Üye
Katılım
22 Eylül 2012
Mesajlar
507
Excel Vers. ve Dili
excel 2010

excel 2013
Altın Üyelik Bitiş Tarihi
06-08-2025
Merhaba

Aşağıdaki kod ile Listbox1 de seçili olan verileri ( multiselect açık ) Listbox2 ye aktarıyorum. Ancak daha önce seçip ve aktarılmış bir verinin tekrardan aktarılmaması için nasıl bir kod oluşturulmalıdır. Listboxlar tek sütundan oluşmakta.

Kod:
    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) = True Then
        ListBox2.AddItem ListBox1.List(i, 0)
    End If
    Next i
 

veyselemre

Özel Üye
Katılım
9 Mart 2005
Mesajlar
3,642
Excel Vers. ve Dili
Pro Plus 2021
Merhaba...
Kod:
Private Sub CommandButton1_Click()
    Dim i
    With CreateObject("Scripting.Dictionary")
        If ListBox2.ListCount > 0 Then
            For Each i In ListBox2.List
                .Item(i) = Null
            Next i
        End If
        If ListBox1.ListCount > 0 Then
            For i = 0 To ListBox1.ListCount - 1
                If ListBox1.Selected(i) Then .Item(ListBox1.List(i)) = Null
            Next i
        End If
        ListBox2.List = .keys
    End With
End Sub
 

walabi

Altın Üye
Katılım
22 Eylül 2012
Mesajlar
507
Excel Vers. ve Dili
excel 2010

excel 2013
Altın Üyelik Bitiş Tarihi
06-08-2025
Dim i With CreateObject("Scripting.Dictionary") If ListBox2.ListCount > 0 Then For Each i In ListBox2.List .Item(i) = Null Next i End If If ListBox1.ListCount > 0 Then For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) Then .Item(ListBox1.List(i)) = Null Next i End If ListBox2.List = .keys End With
Teşekkürler
 
Üst