Listbox'ta Filtreleme

ahmed_ummu

Altın Üye
Katılım
28 Mart 2011
Mesajlar
715
Excel Vers. ve Dili
Excel 2010 Professional Plus 64 Bit
Altın Üyelik Bitiş Tarihi
15-10-2026
Merhaba arkadaşlar.

Aşağıdaki kodda kırmızı renkli olan satırda "unspecified error" hatası veriyor. Listbox1.Clear vs denedim ama yine aynı hatayı verdi. Yardımcı olursanız sevinirim.

Dim aranan As String
Dim sutunharf As String
Dim sutunharfRange As Range
Dim ListBoxVerileri As Variant
Dim i As Integer

Application.ScreenUpdating = False ' Ekran güncellemesini kapat

Sheets("Parametreler").Select

aranan = ComboBox1.Value

' Aranan değeri içeren hücreyi bul
Dim bulunan As Range
Set bulunan = Cells.Find(aranan)

If Not bulunan Is Nothing Then
' Hücrenin sutun harfini al
sutunharf = Split(bulunan.Address, "$")(1)

' Listeleyeceğimiz aralığı belirle
Set sutunharfRange = Sheets("Parametreler").Range(sutunharf & "2:" & sutunharf & Cells(Rows.Count, sutunharf).End(xlUp).Row)

' ListBox1'e verileri yükle
ListBox1.RowSource = sutunharfRange.Address

' ListBox1'deki verileri bir diziye aktar
ListBoxVerileri = ListBox1.List

Do While ListBox1.ListCount > 0
ListBox1.RemoveItem 0 ' BU SATIRDA HATA VERİYOR
Loop

' Seçilen sütundaki verileri filtrele ve ListBox1'e ekle
For i = LBound(ListBoxVerileri, 1) To UBound(ListBoxVerileri, 1)
If UCase(ListBoxVerileri(i, 0)) Like UCase(ComboBox1.Value) & "*" Then
ListBox1.AddItem ListBoxVerileri(i, 0)
End If
Next i
Else
MsgBox "Aranan değer bulunamadı!"
End If

Sheets("Sayfa1").Select
Application.ScreenUpdating = True ' Ekran güncellemesini tekrar aç
 
Üst