Merhaba
ComboBox1 ve ComboBox2 nesnelerim var. ComboBox1 de Hesap Kodları var. ComboBox2 de de alt hesaplarıyla birlikte koşula göre liste alıyorum. Combobox2 de değişince ListView e listelemek istiyorum ancak bir türlü yapamadım.
Private Sub ComboBox1_Change()
Set s2 = Sheets("Hesaplar")
sat2 = s2.Cells(65536, 1).End(xlUp).Row
ComboBox1.RowSource = ""
ComboBox1.ColumnCount = 2
For s = 2 To sat2
If Left(s2.Cells(s, "A"), 3) = CStr(ComboBox2.Value) Then
ComboBox1.AddItem s2.Cells(s, "A") & " " & s2.Cells(s, "B")
'// Bu şekilde iki kolonu çekiyorum ancak diğer ComboBox2 değişince kod çalışmıyor.
'// ComboBox1.AddItem s2.Cells(s, "A")
'// İle veri çekince ComboBox2 değişince kod çalışıyor
End If
Next
End Sub
Private Sub ComboBox2_Change()
ListView1.View = lvwReport
Set S1 = Sheets("Muavin")
say = S1.Range("A65536").End(xlUp).Row
ListView1.ListItems.Clear
With ListView1
j = 1
For j = 1 To say
If CStr(S1.Cells(j, 1)) = CStr(ComboBox1) Then
i = ListView1.ListItems.Count + 1
.ListItems.Add , , S1.Cells(j, 1)
.ListItems(i).SubItems(1) = S1.Cells(j, 2)
.ListItems(i).SubItems(2) = S1.Cells(j, 3)
.ListItems(i).SubItems(3) = S1.Cells(j, 4)
.ListItems(i).SubItems(4) = S1.Cells(j, 5)
.ListItems(i).SubItems(5) = S1.Cells(j, 6)
.ListItems(i).SubItems(6) = Format(S1.Cells(j, 7), "##,##0.00")
.ListItems(i).SubItems(7) = Format(S1.Cells(j, 8), "##,##0.00")
.ListItems(i).SubItems(8) = Format(S1.Cells(j, 9), "##,##0.00")
End If
If j Mod 1 = 0 Then
End If
Next
End With
ListView1.ColumnHeaders(7).Alignment = lvwColumnRight
ListView1.ColumnHeaders(8).Alignment = lvwColumnRight
ListView1.ColumnHeaders(9).Alignment = lvwColumnRight
ListView1.FullRowSelect = True
End Sub
ComboBox ı iki sütun yapıp her iki sütuna da ayrı ayrı veriyi nasıl çekebiliriz. Veri çekince ComboBox değişince başka bir kod çalışacak.
Özetle Örnek dosyada ComboBox2 yani soldaki değişince ComboBox1 de form yüklendiğinde olduğu gibi veriler görünecek. Değişince de ListView e veri gelecek.
Örnek Dosya
http://s5.dosya.tc/server5/e7gvbx/ComboIkiSutun.xls.html
.
ComboBox1 ve ComboBox2 nesnelerim var. ComboBox1 de Hesap Kodları var. ComboBox2 de de alt hesaplarıyla birlikte koşula göre liste alıyorum. Combobox2 de değişince ListView e listelemek istiyorum ancak bir türlü yapamadım.
Private Sub ComboBox1_Change()
Set s2 = Sheets("Hesaplar")
sat2 = s2.Cells(65536, 1).End(xlUp).Row
ComboBox1.RowSource = ""
ComboBox1.ColumnCount = 2
For s = 2 To sat2
If Left(s2.Cells(s, "A"), 3) = CStr(ComboBox2.Value) Then
ComboBox1.AddItem s2.Cells(s, "A") & " " & s2.Cells(s, "B")
'// Bu şekilde iki kolonu çekiyorum ancak diğer ComboBox2 değişince kod çalışmıyor.
'// ComboBox1.AddItem s2.Cells(s, "A")
'// İle veri çekince ComboBox2 değişince kod çalışıyor
End If
Next
End Sub
Private Sub ComboBox2_Change()
ListView1.View = lvwReport
Set S1 = Sheets("Muavin")
say = S1.Range("A65536").End(xlUp).Row
ListView1.ListItems.Clear
With ListView1
j = 1
For j = 1 To say
If CStr(S1.Cells(j, 1)) = CStr(ComboBox1) Then
i = ListView1.ListItems.Count + 1
.ListItems.Add , , S1.Cells(j, 1)
.ListItems(i).SubItems(1) = S1.Cells(j, 2)
.ListItems(i).SubItems(2) = S1.Cells(j, 3)
.ListItems(i).SubItems(3) = S1.Cells(j, 4)
.ListItems(i).SubItems(4) = S1.Cells(j, 5)
.ListItems(i).SubItems(5) = S1.Cells(j, 6)
.ListItems(i).SubItems(6) = Format(S1.Cells(j, 7), "##,##0.00")
.ListItems(i).SubItems(7) = Format(S1.Cells(j, 8), "##,##0.00")
.ListItems(i).SubItems(8) = Format(S1.Cells(j, 9), "##,##0.00")
End If
If j Mod 1 = 0 Then
End If
Next
End With
ListView1.ColumnHeaders(7).Alignment = lvwColumnRight
ListView1.ColumnHeaders(8).Alignment = lvwColumnRight
ListView1.ColumnHeaders(9).Alignment = lvwColumnRight
ListView1.FullRowSelect = True
End Sub
ComboBox ı iki sütun yapıp her iki sütuna da ayrı ayrı veriyi nasıl çekebiliriz. Veri çekince ComboBox değişince başka bir kod çalışacak.
Özetle Örnek dosyada ComboBox2 yani soldaki değişince ComboBox1 de form yüklendiğinde olduğu gibi veriler görünecek. Değişince de ListView e veri gelecek.
Örnek Dosya
http://s5.dosya.tc/server5/e7gvbx/ComboIkiSutun.xls.html
.
