Combox1in Change olayına göre 2 comboboxın Row Source sor

Katılım
4 Ekim 2004
Mesajlar
155
selamlar..
Private Sub ComboBox2_Change()
If ComboBox2.Value = "YURTICI" Then
Label29.Visible = True: TextBox21.Visible = True: CommandButton8.Visible = True: ComboBox9.MaxLength = 13
For w = 2 To Sheets("YURTICI").Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Worksheets("YURTICI").Range("C2:C" & w), Sheets("YURTICI").Cells(w, 3)) = 1 Then ComboBox8.AddItem Sheets("YURTICI").Cells(w, 3).Value
Next
ComboBox8.List = ListSort(ComboBox8.List)
For a = 2 To Sheets("YURTICI").Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Worksheets("YURTICI").Range("B2:B" & a), Sheets("YURTICI").Cells(a, 2)) = 1 Then ComboBox9.AddItem Sheets("YURTICI").Cells(a, 2).Value
Next
ComboBox9.List = ListSort(ComboBox9.List)
" buraya KADAR KODLAR ÇALIÞIYOR" SORUN YOK, tEKRAR YOK
ElseIf ComboBox2.Value <> "YURTICI" Then ' sORUN bU kısımda TextBox21.Value = "": Label29.Visible = False: TextBox21.Visible = False: CommandButton8.Visible = True: ComboBox9.MaxLength = 12

For l = 2 To Sheets("2.SINIF").Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Worksheets("2.SINIF").Range("C2:C" & l), Sheets("2.SINIF").Cells(l, 3)) = 1 Then ComboBox8.AddItem Sheets("2.SINIF").Cells(l, 3).Value
Next
ComboBox8.List = ListSort(ComboBox8.List)

For n = 2 To Sheets("2.SINIF").Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Worksheets("2.SINIF").Range("B2:B" & n), Sheets("2.SINIF").Cells(n, 2)) = 1 Then ComboBox9.AddItem Sheets("2.SINIF").Cells(n, 2).Value
ComboBox9.AddItem Sheets("2.SINIF").Cells(n, 2).Value
Next
ComboBox9.List = ListSort(ComboBox9.List)
End If " BU KISIMDA ROW SOURCE DA TEKRARLAMA VAR, OLMAMASI GEREK? :kafa:
End Sub
 

Levent Menteşoğlu

Administrator
Yönetici
Admin
Katılım
13 Ekim 2004
Mesajlar
16,057
Excel Vers. ve Dili
Excel 2010-32 bit-Türkçe
Excel 365 -32 bit-Türkçe
Birinci hata aşağıdaki kodda end if komutu eksiktir.

[vb:1:8ec985feb6]For l = 2 To Sheets("2.SINIF").Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Worksheets("2.SINIF").Range("C2:C" & l), Sheets("2.SINIF").Cells(l, 3)) = 1 Then ComboBox8.AddItem Sheets("2.SINIF").Cells(l, 3).Value
End if
Next [/vb:1:8ec985feb6]

İkinci sorunuzun cevabı

aşağıdaki satırı iki kez yazmanızdan kaynaklanıyor, bir tanesini silin. Ayrıca burada end if komutunu yine unutmuşsunuz.

[vb:1:8ec985feb6]If WorksheetFunction.CountIf(Worksheets("2.SINIF").Range("B2:B" & n), Sheets("2.SINIF").Cells(n, 2)) = 1 Then ComboBox9.AddItem Sheets("2.SINIF").Cells(n, 2).Value
ComboBox9.AddItem Sheets("2.SINIF").Cells(n, 2).Value 'bu satır gereksizdir
End if
[/vb:1:8ec985feb6]
 
Üst