VBA Listbox arama ve verileri yazdırma

Katılım
24 Kasım 2009
Mesajlar
37
Excel Vers. ve Dili
2007 prof
merhaba üstadlarım,
derlediğim, programımdaherşey çok güzel çalışıyor.
fakat bir arama yaptığımda listebox'a istediğim verileri arabiliyorum.

ve listbox'dan seçim yapınca texboxlara istediğim verileri getirebiliyorum.
fakat işlemlerim bittiğinde,

tekrar listbox'a arama yapamıyorum. konu hakkında bilgisi olanların yardımlarını rica ederim.
örnek dosyam ektedir.
 

Ekli dosyalar

Katılım
24 Kasım 2009
Mesajlar
37
Excel Vers. ve Dili
2007 prof
Private Sub ListBox1_Click()
Sheets("LISTE126").Select
TextBox10 = ListBox1.Column(2)

End Sub
Private Sub CommandButton126_Click()
Dim sh As Worksheet, k As Range
Set sh = Sheets("LISTE126")
TextBox4.Text = "": TextBox3.Text = "": TextBox9.Text = ""
Set k = sh.Range("C3:C" & Rows.Count).Find(TextBox10.Text, , xlValues, xlWhole)
If Not k Is Nothing Then
TextBox4.Text = k.Offset(0, 3).Value
TextBox3.Text = k.Offset(0, 4).Value
TextBox9.Text = k.Offset(0, 5).Value
Else
MsgBox "KOD YOK!!", vbCritical, "UYARI"
End If

End Sub

Private Sub CommandButton108_Click()
Sheets("LISTE126").Select
ad = TextBox1.Text
If ad = "" Then

Exit Sub

End If

s = 0

With ListBox1
.Clear
.ColumnCount = 5
.ColumnWidths = "110,160,170,400,110"

End With
deger1 = ("LISTE126")
deg1 = 0
'Set d = Worksheets(deger1).Range("A3:E1048575").Find(ad, LookAt:=xlPart)
Set d = Worksheets(deger1).Range("A3:E1048575").Find(ad, LookIn:=xlValues)
If Not d Is Nothing Then
firstAddress = d.Address

Do

If d.Row > deg1 Then
If d.Row <> deg1 Then
sat = d.Row
ListBox1.AddItem
ListBox1.List(s, 0) = Cells(sat, "A")
ListBox1.List(s, 1) = Cells(sat, "B")
ListBox1.List(s, 2) = Cells(sat, "C")
ListBox1.List(s, 3) = Cells(sat, "D")
ListBox1.List(s, 4) = Cells(sat, "E")
s = s + 1

End If

End If

deg1 = d.Row
Set d = Worksheets(deger1).Range("A3:E1048575").FindNext(d)
'Set d = Worksheets(deger1).Cells.FindNext(d)
Loop While Not d Is Nothing And d.Address <> firstAddress

End If

End Sub
 
Katılım
24 Kasım 2009
Mesajlar
37
Excel Vers. ve Dili
2007 prof
aslında button108 ilk kullanımda çalışıyor. fakat daha sonra,
126 nolu butona bastığımda, artık tam isim veya açıklama yazmadan çıkmıyor.
aslında 126 botunundaki kodu kaldırdığımda program tekrar çalışıyor.
 
Katılım
9 Mart 2019
Mesajlar
3
Excel Vers. ve Dili
Ofis 2010 Türkçe
Merhaba üç sütunlu bir listbox bulunmakta öncelikle TextBox ve ComboBox lar ile ListBox sa kayıt ekliyorum

Private Sub CommandButton1_Click()
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = ComboBox3.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = ComboBox4.Value
ListBox1.List(ListBox1.ListCount - 1, 2) = TextBox3.Value
End Sub




Daha sonra aşağıdaki ListBox da bulunan verileri sayfaya yazdırmak istiyorum

Private Sub CommandButton2_Click()
sat = ListBox1.ListCount
sut = ListBox1.ColumnCount
Range(Cells(1, 1), Cells(sat, sut)) = ListBox1.List
End Sub


Ancak yukarıdaki kodlar ile hep aynı satıra yazdırmak zorunda kalıyor ve sütunun devamına yazamıyorum.

Kodları aşağıdaki şekilde değiştirdiğimde ise ilk kayıtta "A" sütununun tamamını değiştiriyor. daha ise son dolu satırdan sonra tek tek kayıt yapılor bir türlü anlamadım yardımcı olursanız çok sevinirim.

Private Sub CommandButton2_Click()
SonSat = Range("A1048576").End(xlUp).Row + 1
Sat = ListBox1.ListCount
sut = ListBox1.ColumnCount
Range(Cells(SonSat, 1), Cells(Sat, sut)) = ListBox1.List
End Sub
 
Son düzenleme:
Üst