• DİKKAT

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

Listview'de boş satır sorunu.

Katılım
12 Nisan 2012
Mesajlar
533
Excel Vers. ve Dili
Microsoft office professional plus 2019
Merhaba.Aşağıdaki kod ile Listview 1.kolonuna sayfadaki B-I sutunları arasında bulunan isimleri tarihe göre süzerek yazdırıyorum.Fakat örneğin "C" sutununda tarihe karşılık gelen hücre boşsa listview 1.sutununda bir satır boşluk yazdırarak listeleme yapıyor.Bu durumu If Then Else metoduyla ortadan kaldırabilir miyiz?Yani "C" sutunu boşsa pas geçip "D" sutununu kontrol edecek eğer orasıda boşsa "E" sutununa bakacak.Böyle bir şey yaparak sorunu düzelteceğimi sanıyorum ama başka bir yolda denenebilir tabi.Yardımcı olacak arkadaşa şimdiden Teşekkür Ederim.



Private Sub CommandButton1_Click()
Dim s As Worksheet
Dim i, son, v As Long
Dim List As Object
With UserForm5.ListView1
Set s = Sheets("Veri")
For i = 2 To s.Cells(Rows.Count, "A").End(xlUp).Row
If s.Cells(i, "b").Value <> "" Then
If CDate(s.Cells(i, "a").Value) >= UserForm5.TextBox1.Value And CDate(s.Cells(i, "a").Value) <= UserForm5.TextBox2.Value Then
Set List = .ListItems.Add(, , s.Cells(i, "a").Text)
List.ListSubItems.Add , , s.Cells(i, "b").Text
UserForm5.ListView1.ListItems.Add.SubItems(1) = s.Cells(i, "c")

UserForm5.ListView1.ListItems.Add.SubItems(1) = s.Cells(i, "d")


End If: End If
Next
End With
 

Ekli dosyalar

  • Ekran.2.PNG
    Ekran.2.PNG
    4.9 KB · Görüntüleme: 3
Umarım doğru anlamış ve doğru anlatabilmişimdir.
C++:
Private Sub CommandButton1_Click()
    Dim s As Worksheet
    Dim i, son, v As Long, Veri
    Set s = Sheets("Veri")
    Veri = s.Range("B2:I" & s.Cells(Rows.Count, "A").End(xlUp).Row).Value
    For i = 2 To UBound(Veri)
        If Veri(i, 1) <> "" Then
            'B sütununuz doluysa uygulanacak şartlarınızı yazın
            mySart = True
        ElseIf Veri(i, 2) <> "" Then
            'C sütununuz doluysa uygulanacak şartlarınızı yazın
            mySart = True
        'Elseif    "Diğer kolonlar için dolu sorgularınız" Then
            'Bakacağınız her sütun için bu ElseIf leri çoğaltacaksınız
            'Diğer sütunlarınız doluysa uygulanacak şartlarınız
            'mySart=True
        End If
      
        If mySart Then
            Say = Say + 1
            ListView1.ListItems.Add , , Veri(i, 1)
            For x = 1 To UBound(Veri, 2) - 1
                ListView1.ListItems(Say).SubItems(x) = Veri(i, x + 1)
            Next x
        End If
    Next i
End Sub
 
Çalıştıramadım.Dosya üzerinden bakabilirmisin daha kolay olacak.
ListView1.ListItems(Say).SubItems(x) = Veri(i, x + 1) 'Hata veren satır
 

Ekli dosyalar

Aşağıdaki kodu kullanabilirsiniz.

C++:
Private Sub CommandButton1_Click()
    Dim i As Integer, X As Integer, Veri, say As Integer, Date1 As Date, Date2 As Date
    Date1 = CDate(TextBox1)
    Date2 = CDate(TextBox2)
    Veri = Sheets("Veri").Range("A2:I" & Sheets("Veri").Cells(Rows.Count, "A").End(xlUp).Row).Value
    ListView1.ListItems.Clear
    For i = 1 To UBound(Veri)
        If CDate(Veri(i, 1)) >= Date1 And CDate(Veri(i, 1)) <= Date2 Then
            For X = 2 To UBound(Veri, 2)
                If Veri(i, X) <> "" Then
                    say = say + 1
                    ListView1.ListItems.Add , , Veri(i, 1)
                    ListView1.ListItems(say).SubItems(1) = Veri(i, X)
                End If
            Next X
        End If
    Next i
    Erase Veri: i = Empty: X = Empty: say = Empty
End Sub
 
Tamamdır,çalışıyor.Sağolasın
 
Sen de sağolasın.
 
Geri
Üst