- Katılım
- 24 Kasım 2007
- Mesajlar
- 769
- Excel Vers. ve Dili
- Office 365 - Türkçe
Arkadaşlar ekteki dosyada yapmak istediğim, kullanıcı veri girmek için comboboxları kullanırken aynı zamandada liste kısmındada süzme işlemini yapabilmesi.
makine - referans comboboxları birbirleri ile ilişkili çalışıyor ve sayfa1'e verileri yapıştırıyor
kodları şu şekilde ;
Ben dosyam listbox ekledim
Önce boş dosyada çalıştırdım. kodlar şu şekilde ;
İki kodda ayrı ayrı çalışıyor, fakat iki kodu tek sayfada toplarsam şu şekilde problem yaşıyorum ;
Dosyam ektedir. yardımlarınızı rica ediyorum
makine - referans comboboxları birbirleri ile ilişkili çalışıyor ve sayfa1'e verileri yapıştırıyor
kodları şu şekilde ;
Kod:
Dim con As Object
Private Sub ComboBox1_Change()
ComboBox2.Clear
ComboBox2.Column = con.Execute("select distinct REFERANS from [sayfa2$] where MAKINA ='" & ComboBox1.Text & "'").getrows
End Sub
Private Sub UserForm_Activate()
Set con = CreateObject("adodb.connection")
con.Open "provider=microsoft.jet.oledb.4.0;data source=" & ThisWorkbook.FullName & ";extended properties=""excel 8.0;hdr=yes"""
ComboBox1.Column = con.Execute("select distinct MAKINA from [Sayfa2$]").getrows
End Sub
Private Sub UserForm_Terminate()
Set con = Nothing
End Sub
Private Sub CommandButton1_Click()
Cells(ActiveCell.Row, "D") = ComboBox1.Value
Cells(ActiveCell.Row, "E") = ComboBox2.Value
Cells(ActiveCell.Row, "F") = ComboBox3.Value
Cells(ActiveCell.Row, "I") = ComboBox4.Value
Unload Me
End Sub
Ben dosyam listbox ekledim
Önce boş dosyada çalıştırdım. kodlar şu şekilde ;
Kod:
Private a As Long
Dim i As Long
Private Sub ComboBox1_Change()
For i = 2 To a
If ComboBox1.Text = Cells(i, 4) Then
With ListBox1
.AddItem Cells(i, 4)
.List(.ListCount - 1, 1) = Cells(i, 5)
.List(.ListCount - 1, 2) = Cells(i, 6)
.List(.ListCount - 1, 3) = Cells(i, 7)
.List(.ListCount - 1, 4) = Cells(i, 8)
.List(.ListCount - 1, 5) = Cells(i, 9)
.List(.ListCount - 1, 6) = Cells(i, 10)
.List(.ListCount - 1, 7) = Cells(i, 11)
End With
End If
Next i
End Sub
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 8
ListBox1.ColumnWidths = "50;50;350;50;50;50;50;50;50;50"
ListBox1.RowSource = "sayfa1!D3:L7"
a = Range("D65536").End(3).Row
For i = 3 To Range("D65536").End(3).Row
If WorksheetFunction.CountIf(Range("D3:D" & i), Cells(i, "D")) = 1 Then
ComboBox1.AddItem Cells(i, "D")
End If
Next i
End Sub
İki kodda ayrı ayrı çalışıyor, fakat iki kodu tek sayfada toplarsam şu şekilde problem yaşıyorum ;
Kod:
Private a As Long
Dim i As Long
Dim con As Object
Private Sub ComboBox1_Change()
ComboBox2.Clear
ComboBox2.Column = con.Execute("select distinct REFERANS from [sayfa2$] where MAKINA ='" & ComboBox1.Text & "'").getrows
For i = 2 To a
If ComboBox1.Text = Cells(i, 4) Then
With ListBox1
.AddItem Cells(i, 4)
.List(.ListCount - 1, 1) = Cells(i, 5)
.List(.ListCount - 1, 2) = Cells(i, 6)
.List(.ListCount - 1, 3) = Cells(i, 7)
.List(.ListCount - 1, 4) = Cells(i, 8)
.List(.ListCount - 1, 5) = Cells(i, 9)
.List(.ListCount - 1, 6) = Cells(i, 10)
.List(.ListCount - 1, 7) = Cells(i, 11)
End With
End If
Next i
End Sub
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 8
ListBox1.RowSource = "sayfa1!D3:L7"
a = Range("D65536").End(3).Row
For i = 3 To Range("D65536").End(3).Row
If WorksheetFunction.CountIf(Range("D3:D" & i), Cells(i, "D")) = 1 Then
ComboBox1.AddItem Cells(i, "D")
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Cells(ActiveCell.Row, "D") = ComboBox1.Value
Cells(ActiveCell.Row, "E") = ComboBox2.Value
Cells(ActiveCell.Row, "F") = ComboBox3.Value
Cells(ActiveCell.Row, "I") = ComboBox4.Value
Unload Me
End Sub
Private Sub UserForm_Activate()
Set con = CreateObject("adodb.connection")
con.Open "provider=microsoft.jet.oledb.4.0;data source=" & ThisWorkbook.FullName & ";extended properties=""excel 8.0;hdr=yes"""
ComboBox1.Column = con.Execute("select distinct MAKINA from [Sayfa2$]").getrows
End Sub
Private Sub UserForm_Terminate()
Set con = Nothing
End Sub
Dosyam ektedir. yardımlarınızı rica ediyorum
