Bağlantılı ComboBoxta veri yenileme

Hakan ERDOST

Destek Ekibi
Destek Ekibi
Katılım
12 Eylül 2004
Mesajlar
871
Excel Vers. ve Dili
Excel 2019 Türkçe (Ev)
Excel 2013 Türkçe (Okul)
Birinci ComboBoxtaki kodum;
Kod:
Private Sub ComboBox2_Change()
 Dim c   As Range, _
        s1  As Worksheet, _
        Adr As String
    ComboBox4.Clear
    
    Set s1 = Sheets("DERS_KONU_KAZANIM")
    
    With s1.Range("A:A")
        Set c = .Find(ComboBox2.Value, LookIn:=xlValues)
        If Not c Is Nothing Then
            Adr = c.Address
            Do
                ComboBox4.AddItem s1.Cells(c.Row, "B")
                ComboBox5.AddItem s1.Cells(c.Row, "C")
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> Adr
        End If
    End With
End Sub
UserForm İntialize kodum;
Kod:
Private Sub UserForm_Initialize()
Dim Say, i As Integer, s1 As Worksheet

    Say = WorksheetFunction.CountA(Worksheets("ÖDEV_VERİTABANI").Range("A:A"))
      ListBox1.RowSource = "ÖDEV_VERİTABANI!A2:H" & Say
      ListBox1.ColumnCount = 8

    Set s1 = Sheets("DERS_KONU_KAZANIM")
    
    For i = 1 To s1.Cells(Rows.Count, "A").End(3).Row
        ComboBox2.AddItem s1.Cells(i, "A")
    Next i
       
 End Sub
Forma geçişten sonra ilk girişte ComboBox2 ye bağlı olarak ComboBox4 ve ComboBox5'e veriler filtrelenmiş olarak geliyor.Ancak ikinci kayıttan itibaren ComboBox5'teki liste filtre olmuyor.
 

vardar07

Destek Ekibi
Destek Ekibi
Katılım
19 Mart 2008
Mesajlar
2,154
Excel Vers. ve Dili
Office 2007 Enterprise
Türkçe
Kod:
ComboBox4.Clear
Satırının altına ekleyip deneyiniz.
Kod:
ComboBox5.Clear
 

Hakan ERDOST

Destek Ekibi
Destek Ekibi
Katılım
12 Eylül 2004
Mesajlar
871
Excel Vers. ve Dili
Excel 2019 Türkçe (Ev)
Excel 2013 Türkçe (Okul)
Teşekkürler.Başka bir sorum/sorunum daha var...
Kod:
Option Explicit
Dim isim
Dim liste


Private Sub cmdbul1_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("A2:A" & Range("A2501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(TextBox5)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim
            ListBox1.List(liste, 1) = isim.Offset(0, 1)
            ListBox1.List(liste, 2) = isim.Offset(0, 2)
            ListBox1.List(liste, 3) = isim.Offset(0, 3)
            ListBox1.List(liste, 4) = isim.Offset(0, 4)
            ListBox1.List(liste, 5) = isim.Offset(0, 5)
            ListBox1.List(liste, 6) = Format(isim.Offset(0, 6), "dd.mm.yyyy")
            ListBox1.List(liste, 7) = Format(isim.Offset(0, 7), "dd.mm.yyyy")
            ListBox1.List(liste, 8) = isim.Offset(0, 8)
           
            
     End If
Next
End Sub

Private Sub cmdbul2_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8
For Each isim In Range("B2:B" & Range("B62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(ComboBox1)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -1)
            ListBox1.List(liste, 1) = isim
            ListBox1.List(liste, 2) = isim.Offset(0, 1)
            ListBox1.List(liste, 3) = isim.Offset(0, 2)
            ListBox1.List(liste, 4) = isim.Offset(0, 3)
            ListBox1.List(liste, 5) = isim.Offset(0, 4)
            ListBox1.List(liste, 6) = isim.Offset(0, 5)
            ListBox1.List(liste, 7) = Format(isim.Offset(0, 6), "dd.mm.yyyy")
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 7), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = isim.Offset(0, 8)
           
            
     End If
Next
End Sub

Private Sub cmdbul3_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("C2:C" & Range("C62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(ComboBox2)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -2)
            ListBox1.List(liste, 1) = isim.Offset(0, -1)
            ListBox1.List(liste, 2) = isim
            ListBox1.List(liste, 3) = isim.Offset(0, 1)
            ListBox1.List(liste, 4) = isim.Offset(0, 2)
            ListBox1.List(liste, 5) = isim.Offset(0, 3)
            ListBox1.List(liste, 6) = isim.Offset(0, 4)
            ListBox1.List(liste, 7) = isim.Offset(0, 5)
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 6), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = Format(isim.Offset(0, 7), "dd.mm.yyyy")
            
           
            
     End If
Next
End Sub

Private Sub cmdbul4_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("D2:D" & Range("D62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(ComboBox4)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -3)
            ListBox1.List(liste, 1) = isim.Offset(0, -2)
            ListBox1.List(liste, 2) = isim.Offset(0, -1)
            ListBox1.List(liste, 3) = isim
            ListBox1.List(liste, 4) = isim.Offset(0, 1)
            ListBox1.List(liste, 5) = isim.Offset(0, 2)
            ListBox1.List(liste, 6) = isim.Offset(0, 3)
            ListBox1.List(liste, 7) = isim.Offset(0, 4)
            ListBox1.List(liste, 8) = isim.Offset(0, 5)
            ListBox1.List(liste, 9) = Format(isim.Offset(0, 6), "dd.mm.yyyy")
          
           
            
     End If
Next

End Sub

Private Sub cmdbul5_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("E2:E" & Range("E62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(ComboBox5)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -4)
            ListBox1.List(liste, 1) = isim.Offset(0, -3)
            ListBox1.List(liste, 2) = isim.Offset(0, -2)
            ListBox1.List(liste, 3) = isim.Offset(0, -1)
            ListBox1.List(liste, 4) = isim
            ListBox1.List(liste, 5) = isim.Offset(0, 1)
            ListBox1.List(liste, 6) = isim.Offset(0, 2)
            ListBox1.List(liste, 7) = isim.Offset(0, 3)
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 4), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = isim.Offset(0, 5)
           
            
     End If
Next
End Sub

Private Sub cmdbul6_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("F2:F" & Range("F62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(TextBox3)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -5)
            ListBox1.List(liste, 1) = isim.Offset(0, -4)
            ListBox1.List(liste, 2) = isim.Offset(0, -3)
            ListBox1.List(liste, 3) = isim.Offset(0, -2)
            ListBox1.List(liste, 4) = isim.Offset(0, -1)
            ListBox1.List(liste, 5) = isim
            ListBox1.List(liste, 6) = isim.Offset(0, 1)
            ListBox1.List(liste, 7) = isim.Offset(0, 2)
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 3), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = isim.Offset(0, 4)

           
            
     End If
Next

End Sub

Private Sub cmdbul7_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("G2:G" & Range("G62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(TextBox4)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -6)
            ListBox1.List(liste, 1) = isim.Offset(0, -5)
            ListBox1.List(liste, 2) = isim.Offset(0, -4)
            ListBox1.List(liste, 3) = isim.Offset(0, -3)
            ListBox1.List(liste, 4) = isim.Offset(0, -2)
            ListBox1.List(liste, 5) = isim.Offset(0, -1)
            ListBox1.List(liste, 6) = isim
            ListBox1.List(liste, 7) = isim.Offset(0, 1)
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 2), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = isim.Offset(0, 3)
            
     End If
Next

End Sub

Private Sub cmdbul8_Click()
ListBox1.RowSource = Empty
ListBox1.Clear
ListBox1.ColumnCount = 8

For Each isim In Range("H2:H" & Range("H62501").End(xlUp).Row)
    If UCase(LCase(isim)) Like UCase(LCase(ComboBox3)) & "*" Then
        liste = ListBox1.ListCount
            ListBox1.AddItem
            ListBox1.List(liste, 0) = isim.Offset(0, -7)
            ListBox1.List(liste, 1) = isim.Offset(0, -6)
            ListBox1.List(liste, 2) = isim.Offset(0, -5)
            ListBox1.List(liste, 3) = isim.Offset(0, -4)
            ListBox1.List(liste, 4) = isim.Offset(0, -3)
            ListBox1.List(liste, 5) = isim.Offset(0, -2)
            ListBox1.List(liste, 6) = isim.Offset(0, -1)
            ListBox1.List(liste, 7) = isim
            ListBox1.List(liste, 8) = Format(isim.Offset(0, 1), "dd.mm.yyyy")
            ListBox1.List(liste, 9) = isim.Offset(0, 2)
            
     End If
Next

End Sub




Private Sub UserForm_Initialize()
Dim Say, i As Integer
 Dim DİZİA As New Collection, HÜCRE As Range, VERİ As Variant
    
    On Error Resume Next
    Sheets("DERS_KONU_KAZANIM").Select
    For Each HÜCRE In Range("A2:A" & Range("A65536").End(3).Row)
        DİZİA.Add HÜCRE.Value, CStr(HÜCRE.Value)
    Next
    
    On Error GoTo 0
    
    For Each VERİ In DİZİA
        ComboBox2.AddItem VERİ
    Next
    Say = WorksheetFunction.CountA(Worksheets("ÖDEV_VERİTABANI").Range("A:A"))
      ListBox1.RowSource = "ÖDEV_VERİTABANI!A2:H" & Say
      ListBox1.ColumnCount = 8
    
    End Sub




Private Sub ComboBox2_Change()
    Dim DİZİB As New Collection, HÜCRE As Range, VERİ As Variant
    
    On Error Resume Next
     Sheets("DERS_KONU_KAZANIM").Select
    For Each HÜCRE In Range("A2:A" & Range("A65536").End(3).Row)
        If HÜCRE.Value = ComboBox2 Then
        DİZİB.Add HÜCRE.Offset(0, 1).Value, CStr(HÜCRE.Offset(0, 1).Value)
        End If
    Next
    
    On Error GoTo 0
    
    ComboBox4.Clear
    
    For Each VERİ In DİZİB
        ComboBox4.AddItem VERİ
    Next
End Sub


Private Sub ComboBox4_Change()
    Dim DİZİC As New Collection, HÜCRE As Range, VERİ As Variant
    
    On Error Resume Next
     Sheets("DERS_KONU_KAZANIM").Select
    For Each HÜCRE In Range("A2:A" & Range("A65536").End(3).Row)
        If HÜCRE.Value = ComboBox2 And CStr(HÜCRE.Offset(0, 1).Value) = ComboBox4 Then
        DİZİC.Add HÜCRE.Offset(0, 2).Value, CStr(HÜCRE.Offset(0, 2).Value)
        End If
    Next
    
    On Error GoTo 0
    
    ComboBox5.Clear
    
    For Each VERİ In DİZİC
        ComboBox5.AddItem VERİ
    Next
End Sub


Private Sub CommandButton1_Click()
Sheets("ÖDEV_VERİTABANI").Select
If Range("A2") = "" Then
Range("A2").Select
ActiveCell = 1
ActiveCell.Offset(0, 1).Value = ComboBox1.Value
ActiveCell.Offset(0, 2).Value = ComboBox2.Value
ActiveCell.Offset(0, 3).Value = ComboBox4.Value
ActiveCell.Offset(0, 4).Value = ComboBox5.Value
ActiveCell.Offset(0, 5).Value = TextBox3.Value
ActiveCell.Offset(0, 6).Value = TextBox4.Value
ActiveCell.Offset(0, 7).Value = ComboBox3.Value

Else
[a65536].End(xlUp).Offset(1, 0).Select
ActiveCell = ActiveCell.Offset(-1, 0) + 1

ActiveCell.Offset(0, 1).Value = ComboBox1.Value
ActiveCell.Offset(0, 2).Value = ComboBox2.Value
ActiveCell.Offset(0, 3).Value = ComboBox4.Value
ActiveCell.Offset(0, 4).Value = ComboBox5.Value
ActiveCell.Offset(0, 5).Value = TextBox3.Value
ActiveCell.Offset(0, 6).Value = TextBox4.Value
ActiveCell.Offset(0, 7).Value = ComboBox3.Value
 
End If
ComboBox1 = ""
ComboBox2 = ""
ComboBox4 = ""
ComboBox5 = ""
TextBox3 = ""
TextBox4 = ""
ComboBox3 = ""
    MsgBox "Kayıt işlemi tamamlanmıştır.", vbInformation, "Kayıt İşlemi"


End Sub

Private Sub CommandButton2_Click()
Unload Me
UserForm3.Show
End Sub

Private Sub CommandButton3_Click()
Dim sat As String, cevap As String
sat = ListBox1.ListIndex + 2
cevap = MsgBox("DEĞİŞTİRMEK İSTEDİĞİNİZDEN EMİNMİSİNİZ!", vbYesNo, "")
If cevap = vbNo Then Exit Sub
Sheets("ÖDEV_VERİTABANI").Select
ListBox1.RowSource = ""
Cells(sat, "b") = ComboBox1.Value
Cells(sat, "c") = ComboBox2.Value
Cells(sat, "d") = ComboBox4.Value
Cells(sat, "e") = ComboBox5.Value
Cells(sat, "f") = TextBox3.Value
Cells(sat, "g") = TextBox4.Value
Cells(sat, "h") = ComboBox3.Value
ComboBox1 = ""
 ComboBox2 = ""
ComboBox4 = ""
ComboBox5 = ""
 TextBox3 = ""
 TextBox4 = ""
ComboBox3 = ""
UserForm_Initialize

End Sub

Private Sub CommandButton4_Click()
Sheets("ÖDEV_VERİTABANI").Select
Dim sor As String, sat As String
sor = MsgBox("Silmek istediğinizden eminmisiniz?", vbYesNo)
If sor = vbNo Then Exit Sub
sat = ListBox1.ListIndex + 2
Range("A" & sat).Interior.ColorIndex = 25
Range("B" & sat & ":H" & sat).Delete
[a65536].End(3).Delete
UserForm_Initialize
MsgBox "SEÇİLEN VERİ SİLİNMİŞTİR"
End Sub

Private Sub ListBox1_Click()
Dim isim As String
On Error Resume Next
isim = ListBox1.ListIndex
TextBox5.Text = ListBox1.List(isim, 0)
ComboBox1.Text = ListBox1.List(isim, 1)
ComboBox2.Text = ListBox1.List(isim, 2)
ComboBox4.Text = ListBox1.List(isim, 3)
ComboBox5.Text = ListBox1.List(isim, 4)
TextBox3.Text = ListBox1.List(isim, 5)
TextBox4.Text = ListBox1.List(isim, 6)
ComboBox3.Text = ListBox1.List(isim, 7)

Sheets("ÖDEV_VERİTABANI").Range(Cells(isim + 2, 1), Cells((isim + 2), 4)).Select
End Sub

Private Sub TextBox3_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox3.Value = Format(Date, "dd.mm.yyyy")
End Sub

Private Sub TextBox4_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4.Value = Format(Date, "dd.mm.yyyy")
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Say As Integer

    Say = WorksheetFunction.CountA(Worksheets("ÖDEV_VERİTABANI").Range("A:A"))
      ListBox1.RowSource = "ÖDEV_VERİTABANI!A2:H" & Say
      ListBox1.ColumnCount = 8
      ListBox1.ColumnWidths = "30;65;75;90;120;90;90;35"
Bu kodlar Halit beyin bir çalışmasından. Kendime uyarladım. Ancak isim = ListBox1.ListIndex satırnda hata veriyor. Deişken tanımladım ancak veriyi süzmüyor.
 

vardar07

Destek Ekibi
Destek Ekibi
Katılım
19 Mart 2008
Mesajlar
2,154
Excel Vers. ve Dili
Office 2007 Enterprise
Türkçe
Örnek ekleme şansınız varsa bir bakalım. Şurdan demek yanlış olur.
 

Hakan ERDOST

Destek Ekibi
Destek Ekibi
Katılım
12 Eylül 2004
Mesajlar
871
Excel Vers. ve Dili
Excel 2019 Türkçe (Ev)
Excel 2013 Türkçe (Okul)
Teşekkürler, sorun çözüldü.Değişken tanımlamalarda sorun varmış.
 
Üst