Listbox'da veri aktarma sorunu

Katılım
12 Nisan 2012
Mesajlar
533
Excel Vers. ve Dili
Microsoft office professional plus 2019
Altın Üyelik Bitiş Tarihi
18-12-2024
Merhaba Arkadaşlar.Aşağıdaki kod ile aynı anda Listbox1'den seçili veriyi Listbox3'e ve excel sayfasına kaydetmek istiyorum fakat listbox3'e ilave yaptığım zaman girdiğim son veri yerine Listbox3'ün tümündeki verileri excel sayfasına aktarıyor yapmak istediğim son girdiğim veriyi excel sayfasına aktarmak.Yardımcı olabilirseniz sevinirim.

xrow = Sheets("Liste").Cells(Rows.Count, "a").End(3).Row
For sat = 0 To ListBox3.ListCount - 1
For sut = 1 To 7
Sheets("Liste").Cells(sat + 1 + xrow, sut) = ListBox3.List(sat, sut - 1)

Next
Next



If ListBox1.ListIndex = -1 Then Exit Sub
Say = 1
For Bak = 0 To ListBox3.ListCount - 1
If ListBox3.List(Bak, 1) = ListBox1.List(ListBox1.ListIndex, 0) Then
Say = Int(ListBox3.List(Bak, 4)) + 1
Satir = Bak
Exit For
End If
Next
If Say = 1 Then

ListBox3.AddItem
Satir = ListBox3.ListCount - 1
End If
If ListBox1.ListIndex = -1 Then Exit Sub
For a = ListBox1.ListCount - 1 To 0 Step -1
If ListBox1.Selected(a) = True Then


ListBox3.List(Satir, 1) = ListBox1.List(ListBox1.ListIndex, 0)
ListBox3.List(Satir, 2) = ListBox1.List(ListBox1.ListIndex, 1)
ListBox3.List(Satir, 3) = TextBox1.Text
ListBox3.List(Satir, 4) = Say
ListBox3.List(Satir, 5) = Say * ListBox1.List(ListBox1.ListIndex, 1)
End If:
Next:
 
Katılım
31 Aralık 2014
Mesajlar
1,845
Excel Vers. ve Dili
Excel 2010
Merhaba
Yukarıdaki kodlarınız aşağıdaki gibi düzenlenebilir
Sanırım kodlarınız yalnızca ekleme yapmıyor değişiklikde yapıyor, bir deneyelim.
Kod:
If ListBox1.ListIndex = -1 Then Exit Sub
say = 1
For bak = 0 To ListBox3.ListCount - 1
If ListBox3.List(bak, 1) = ListBox1.List(ListBox1.ListIndex, 0) Then
say = Int(ListBox3.List(bak, 4)) + 1
satir = bak
xow = Sheets("Liste").Cells(Rows.Count, "B").End(3).Row
xow = (xow - ListBox3.ListCount) + bak + 1
Exit For
End If
Next
If say = 1 Then

ListBox3.AddItem
satir = ListBox3.ListCount - 1
End If
If ListBox1.ListIndex = -1 Then Exit Sub
For a = ListBox1.ListCount - 1 To 0 Step -1
If ListBox1.Selected(a) = True Then
ListBox3.List(satir, 1) = ListBox1.List(ListBox1.ListIndex, 0)
ListBox3.List(satir, 2) = ListBox1.List(ListBox1.ListIndex, 1)
ListBox3.List(satir, 3) = TextBox1.Text
ListBox3.List(satir, 4) = say
ListBox3.List(satir, 5) = say * ListBox1.List(ListBox1.ListIndex, 1)
xrow = IIf(xow = 0, Sheets("Liste").Cells(Rows.Count, "B").End(3).Row + 1, xow)
For sut = 1 To 7
Sheets("Liste").Cells(xrow, sut) = ListBox3.List(satir, sut - 1)
Next
End If:
Next:
 
Katılım
12 Nisan 2012
Mesajlar
533
Excel Vers. ve Dili
Microsoft office professional plus 2019
Altın Üyelik Bitiş Tarihi
18-12-2024
Yaptığım bütün denemelerden olumlu sonuç aldım.Katkınız için Teşekkür ederim.Değişikliği satır silme ve yeniden girme şeklinde yapıyorum.Ekleme yapma konusunda da aynı ürünü tek satırda kendisi ekleme yapıyor.Alt alta yazmıyor.
 
Son düzenleme:
Üst