Çözüldü Dinamik text aramalı ListBox

KoNFiCuS

Altın Üye
Katılım
18 Mayıs 2011
Mesajlar
56
Excel Vers. ve Dili
Office 365 TR - 64 Bit
Altın Üyelik Bitiş Tarihi
08-03-2028
Merhaba Üstadlar,

Eski kullanmış olduğum bir ListBox objesinde arama yapılan text soldan sağa aynı olması gerekiyordu, aşağıdaki kodu içerisinde geçen kelimelere göre arama yapacağı şekilde nasıl güncelleyebilirim?

Kod:
Private Sub TextBox1_Change()
On Error GoTo yok
Dim oteladi As Range
ListBox1.Clear
For Each oteladi In ThisWorkbook.Worksheets("PivotDB").Range("AV2:AV" & ThisWorkbook.Worksheets("PivotDB").Range("AV65530").End(1).Row)
    If InStr(1, oteladi, TextBox1.Text, vbTextCompare) > 0 Then
        
        ListBox1.AddItem
        ListBox1.List(ListBox1.ListCount - 1, 0) = oteladi
        ListBox1.List(ListBox1.ListCount - 1, 1) = oteladi.Offset(0, 1)
        ListBox1.List(ListBox1.ListCount - 1, 2) = oteladi.Offset(0, 2)
    End If
Next oteladi
Exit Sub
yok:
ListBox1.Clear
End Sub
ayrıca Offset deki 2. seçenek yani "ListBox1.List(ListBox1.ListCount - 1, 2) = oteladi.Offset(0, 2)" bu listbox a gelmiyor.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,536
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Merhaba,

Uygulama yaptığınız örnek dosyanızı paylaşabilirmisiniz.
 

KoNFiCuS

Altın Üye
Katılım
18 Mayıs 2011
Mesajlar
56
Excel Vers. ve Dili
Office 365 TR - 64 Bit
Altın Üyelik Bitiş Tarihi
08-03-2028
Başka kaynakları araştırarak da olsa bir kendimce bir yanıt buldum.

Kod:
Private Sub TextBox1_Change()

ListBox1.Clear

List = Worksheets("PivotDB").Range("AV2:AV" & ThisWorkbook.Worksheets("PivotDB").Range("AV65530").End(1).Row)

For t = LBound(List) To UBound(List)
    If InStr(1, List(t, 1), Trim(TextBox1), vbTextCompare) Then
        ListBox1.AddItem List(t, 1)
    End If
Next

End Sub
Ama bu seferde sadece mesela ismi getiriyor yanındaki bilgileri getirmiyor,

ListBox1.List(ListBox1.ListCount - 1, 1) = List.Offset(0, 1)
ListBox1.List(ListBox1.ListCount - 1, 2) = List.Offset(0, 2)

denedim olmadı.
 

KoNFiCuS

Altın Üye
Katılım
18 Mayıs 2011
Mesajlar
56
Excel Vers. ve Dili
Office 365 TR - 64 Bit
Altın Üyelik Bitiş Tarihi
08-03-2028
Ufak bir değişiklikle başardım.

Kod:
List = Worksheets("PivotDB").Range("AV2:Ax" & ThisWorkbook.Worksheets("PivotDB").Range("Ax65530").End(1).Row)

For t = LBound(List) To UBound(List)
    If InStr(1, List(t, 1), Trim(TextBox1), vbTextCompare) Then
        ListBox1.AddItem
        ListBox1.List(ListBox1.ListCount - 1, 0) = List(t, 1)
        ListBox1.List(ListBox1.ListCount - 1, 1) = List(t, 2)
        ListBox1.List(ListBox1.ListCount - 1, 2) = List(t, 3)
 
Üst