Arkadaşlar aşağıdaki kod ile listboxta listelenen verinin istediğim sütununda veri araması yapabiliyorum. Bu kodları listview nesnesine uyarlayamadım. Listboxta çalışan kodları listviewe göre düzenleyebilir misiniz lütfen
Kodların ListBoxta çalışan halini ve ListViewde düzenlenecek halini ekteki dosyalarda gönderdim. Yardımlarınız için şimdiden teşekkürler arkadaşlar.
Kod:
Private Sub CommandButton5_Click() 'Search Button
Dim sat, s As Integer
Dim deg1, deg2 As String
If TextBox13.Value = "" Then
MsgBox "Please enter a value", vbExclamation
TextBox13.SetFocus
Exit Sub
End If
If ComboBox1.Value = "" Or ComboBox1.Value = "-" Then
MsgBox "Choose a filter field", vbExclamation
ComboBox1.SetFocus
Exit Sub
End If
For a = 1 To 12 ' Clear textboxes(1-12)
Controls("textbox" & a) = ""
Next
With ListBox1
.Clear
.ColumnCount = 12
.ColumnWidths = "92;140;110;65;65;35;40;65;65;115;150;65"
End With
Call Main 'Progress Bar
deg2 = TextBox13.Value
Select Case ComboBox1.Value
Case "First Name"
For sat = 2 To Cells(65536, "a").End(xlUp).row
Set deg1 = Cells(sat, "a")
If UCase(deg1) Like UCase(deg2) & "*" Then
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")
ListBox1.List(s, 5) = Cells(sat, "F")
ListBox1.List(s, 6) = Cells(sat, "G")
ListBox1.List(s, 7) = Cells(sat, "H")
ListBox1.List(s, 8) = Cells(sat, "I")
ListBox1.List(s, 9) = Cells(sat, "J")
ListBox1.List(s, 10) = Cells(sat, "K")
ListBox1.List(s, 11) = Cells(sat, "L")
s = s + 1
End If: Next
Case "Company"
For sat = 2 To Cells(65536, "b").End(xlUp).row
Set deg1 = Cells(sat, "b")
If UCase(deg1) Like UCase(deg2) & "*" Then
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")
ListBox1.List(s, 5) = Cells(sat, "F")
ListBox1.List(s, 6) = Cells(sat, "G")
ListBox1.List(s, 7) = Cells(sat, "H")
ListBox1.List(s, 8) = Cells(sat, "I")
ListBox1.List(s, 9) = Cells(sat, "J")
ListBox1.List(s, 10) = Cells(sat, "K")
ListBox1.List(s, 11) = Cells(sat, "L")
s = s + 1
End If: Next
Case "City"
For sat = 2 To Cells(65536, "d").End(xlUp).row
Set deg1 = Cells(sat, "d")
If UCase(deg1) Like UCase(deg2) & "*" Then
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")
ListBox1.List(s, 5) = Cells(sat, "F")
ListBox1.List(s, 6) = Cells(sat, "G")
ListBox1.List(s, 7) = Cells(sat, "H")
ListBox1.List(s, 8) = Cells(sat, "I")
ListBox1.List(s, 9) = Cells(sat, "J")
ListBox1.List(s, 10) = Cells(sat, "K")
ListBox1.List(s, 11) = Cells(sat, "L")
s = s + 1
End If: Next
Case "Estimated Revenue"
For sat = 2 To Cells(65536, "l").End(xlUp).row
Set deg1 = Cells(sat, "l")
If deg1 Like deg2 & "*" Then
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")
ListBox1.List(s, 5) = Cells(sat, "F")
ListBox1.List(s, 6) = Cells(sat, "G")
ListBox1.List(s, 7) = Cells(sat, "H")
ListBox1.List(s, 8) = Cells(sat, "I")
ListBox1.List(s, 9) = Cells(sat, "J")
ListBox1.List(s, 10) = Cells(sat, "K")
ListBox1.List(s, 11) = Cells(sat, "L")
s = s + 1
End If: Next
End Select
Label15.Caption = ListBox1.ListCount
End Sub
Ekli dosyalar
-
162 KB Görüntüleme: 13
-
584.5 KB Görüntüleme: 16