• DİKKAT

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

2 Listbox Arası Data Transferi

Katılım
20 Nisan 2012
Mesajlar
78
Excel Vers. ve Dili
Ofis 365 TR 32 Bit
Merhabalar,

Userform'da 2 tane listbox var, listbox1'den listbox2 ye secilen verileri transfer etmek istiyorum. Aşağıdaki kod ile taşıma yaptığımda sade ilk 2 column veri listbox2 ye geçiyor kalan 7 bölüm geçmiyor. hepsinin geçmesi için kodu nasıl değiştirmem gerek ?

Dim z As Long
ListBox2.ColumnCount = 9
For z = Me.ListBox1.ListCount - 1 To 0 Step -1
If Me.ListBox1.Selected(z) Then
Me.ListBox2.AddItem Me.ListBox1.List(z, 0)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 1) = Me.ListBox1.List(z, 1)
Me.ListBox1.RemoveItem (z)

End If

Next
 
Merhaba.
Kod:
    Dim Liste As Integer
    ListBox2.AddItem
    For Liste = 0 To ListBox1.ColumnCount
        ListBox2.List(ListBox2.ListCount - 1, Liste) = ListBox1.List(ListBox1.ListIndex, Liste)
    Next
 
Merhaba.
Kod:
    Dim Liste As Integer
    ListBox2.AddItem
    For Liste = 0 To ListBox1.ColumnCount
        ListBox2.List(ListBox2.ListCount - 1, Liste) = ListBox1.List(ListBox1.ListIndex, Liste)
    Next
Kendi kodumla bunu nasıl birleştiricem onu anlamadım. Sadece bu kodu yaparsam sadece 1 column veri geliyor o da ilk olan
 
Son düzenleme:
Listbox2'nin ColumnCount özelliğine 9 yazmalısınız.
Yada kod ile ColumnCount =9 yazmalısınız.
 
Listbox2'nin ColumnCount özelliğine 9 yazmalısınız.
Yada kod ile ColumnCount =9 yazmalısınız.
Çok teşekkürler o şekilde gayet güzel çalıştı. Tek sorun tek tek seçip aktarinca sorun yok geçiyor. Lakin eğer 2 seçim yaparsam veya daha fazla sadece 1 tanesi aktarilıyor
 
Deneyiniz.
Kod:
    Dim Liste As Integer
    Dim Satir As Integer
    For Liste = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(Liste) Then
            ListBox2.AddItem
            For Satir = 0 To ListBox1.ColumnCount
                ListBox2.List(ListBox2.ListCount - 1, Satir) = ListBox1.List(Liste, Satir)
            Next
        End If
    Next
 
Deneyiniz.
Kod:
    Dim Liste As Integer
    Dim Satir As Integer
    For Liste = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(Liste) Then
            ListBox2.AddItem
            For Satir = 0 To ListBox1.ColumnCount
                ListBox2.List(ListBox2.ListCount - 1, Satir) = ListBox1.List(Liste, Satir)
            Next
        End If
    Next

@Muzaffer Ali bey, harika çalıştı elinize sağlık. Ilave bir sorum olacak.

listbox1 de 9. satırda rakamlar var, ben bu rakamları listbox'un altında aşağıdaki formül ile topluyorum ve gayet güzel çalışıyor. Lakin listbox1'den verdiğiniz formül ile listbox2 ye taşıdığımda listbox2 altındaki alanda toplama işlemi malesef olmuyor. Nerede hata yapıyorum ?

247970

Listbox1'i toplayan formül:

Sub topla()
For Row = 0 To UserForm12.ListBox1.ListCount - 1
Sum = Sum + Val(UserForm12.ListBox1.List(Row, 8))
Next Row
UserForm12.TextBox1 = Sum

End Sub


Listbox2'yi toplayan fomül:
Sub topla2()
For Row = 0 To UserForm12.ListBox2.ListCount - 1
Sum = Sum + Val(UserForm12.ListBox2.List(Row, 8))
Next Row
UserForm12.TextBox2 = Sum


End Sub
 
Aşağıdaki gibi bir msgbox ile toplanacak değeri kontrol edin.

Kod:
Sub topla2()
    For Row = 0 To UserForm12.ListBox2.ListCount - 1
        MsgBox Val(UserForm12.ListBox2.List(Row, 8))
        Sum = Sum + Val(UserForm12.ListBox2.List(Row, 8))
    Next Row
    UserForm12.TextBox2 = Sum


End Sub

sorunu bulup çözemezseniz, dosyanızı paylaşın kontrol edelim.
 
Aşağıdaki gibi bir msgbox ile toplanacak değeri kontrol edin.

Kod:
Sub topla2()
    For Row = 0 To UserForm12.ListBox2.ListCount - 1
        MsgBox Val(UserForm12.ListBox2.List(Row, 8))
        Sum = Sum + Val(UserForm12.ListBox2.List(Row, 8))
    Next Row
    UserForm12.TextBox2 = Sum


End Sub

sorunu bulup çözemezseniz, dosyanızı paylaşın kontrol edelim.
@Muzaffer Ali
Malesef yapamadım. Module4 içerisinde kod. İncelemek için userform12 çalıştırmanız gerekiyor
 

Ekli dosyalar

Modulr3 deki kodu aşağıdaki gibi yapınca toplama yapıyor.

Kod:
Sub topla()
    For Row = 0 To UserForm12.ListBox1.ListCount - 1
        Sum = Sum + Val(UserForm12.ListBox1.List(Row, 8))
    Next Row
    UserForm12.TextBox1 = Sum
    
    Sum = 0
    For Row = 0 To UserForm12.ListBox2.ListCount - 1
        Sum = Sum + Val(UserForm12.ListBox2.List(Row, 8))
    Next Row
    UserForm12.TextBox2 = Sum
End Sub
 
Geri
Üst