• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Benzersiz kayıtları comboboxda göstermek?

udentr2002

Altın Üye
Katılım
5 Kasım 2006
Mesajlar
1,503
Excel Vers. ve Dili
iş yerinde Office 365
evde Office 365
Merhaba arkadaşlar c stünunda tekrarlayan kayıtlarım var ben bu kayıtları comboboxa alırken tekrarsız olarak gösterebilmem için ne yapabilrim. Yani combobox açılınca o stünda birbirini tekrarlayan kayıtların sadece bir defa görünebilmesi için nasıl bir kod yazabilirim.
 
Gelişmiş süzgeç ile benzersiz olanları başka alana kopyalayıp oradan çekebilirsiniz.
 
Private Sub UserForm_Initialize()
For x = 2 To Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Range("a2:a" & x), Cells(x, 1)) = 1 Then
ComboBox1.AddItem Cells(x, 1).Value
End If
Next
End Sub

Yukarıdaki Kodu bir deneyin. Gününüz aydın olsun.
 
Private Sub UserForm_Initialize()
For x = 2 To Cells(65536, 1).End(xlUp).Row
If WorksheetFunction.CountIf(Range("c2:c" & x), Cells(x, 1)) = 1 Then
ComboBox1.AddItem Cells(x, 1).Value
End If
Next
End Sub

Yani C sütunu olacaktı.
 
EC yavuz hocam ilginiz için teşekkür ederim fakat kodları denedim ama çalışmadı
 
Sayın ECYavuzun yazdığı kodlardaki kırmızı yeri değiştirin.:cool:
Kod:
Private Sub UserForm_Initialize()
For x = 2 To Cells(65536, [B][COLOR="Red"]3[/COLOR][/B]).End(xlUp).Row
If WorksheetFunction.CountIf(Range("c2:c" & x), Cells(x, [B][COLOR="Red"]3[/COLOR][/B])) = 1 Then
ComboBox1.AddItem Cells(x,[COLOR="red"][B] 3[/B][/COLOR]).Value
End If
Next
End Sub
 
Hocam çok teşekkür ederim şimdi oldu diğer ilgilenen hocalarımada teşekkürler
 
Hocam yanlız şöyle bir sorun çıkıyor; userformu açınca combobox benzersiz kayıtları gösteriyor. yanlız form üzerinde kaydet tuşu var ve bu kayıt tuşuna bastığımda bu defa comboboxdaki benzersiz kayıtları 2 şer defa gösteriyor.
kayıt tuşunun en son satırında userform_initialize kodu mevcut bunun için ne yapabilirim

benim kodlar usuerform initialize kodlarım şöyle;
Kod:
Private Sub UserForm_Initialize()


ListBox1.ColumnCount = 12
ListBox1.ColumnWidths = "35;50;100;60;100;100;70;80;35;50;70;150"
ListBox1.RowSource = "Veri!a2:l" & Sheets("Veri").Range("a65536").End(3).Row


For X = 3 To Cells(65536, 3).End(xlUp).Row
If WorksheetFunction.CountIf(Range("c3:c" & X), Cells(X, 3)) = 1 Then
ComboBox1.AddItem Cells(X, 3).Value
End If
Next


For Y = 3 To Cells(65536, 5).End(xlUp).Row
If WorksheetFunction.CountIf(Range("e3:e" & Y), Cells(Y, 5)) = 1 Then
ComboBox2.AddItem Cells(Y, 5).Value
End If
Next

For z = 3 To Cells(65536, 6).End(xlUp).Row
If WorksheetFunction.CountIf(Range("f3:f" & z), Cells(z, 6)) = 1 Then
ComboBox3.AddItem Cells(z, 6).Value
End If
Next

End Sub

form üzerindeki verileri sayfaya aktaran kodlarım ise aşağıdaki gibi;
Kod:
Private Sub CommandButton1_Click()
On Error Resume Next
Set s1 = Sheets("Veri")
TextBox1.Value = Format(TextBox1.Value, "dd.mm.yyyy")


t1 = CDbl(TextBox5)
t2 = CDbl(TextBox6)
t3 = CDbl(TextBox7)

t1 = t1 * 1
t2 = t2 * 1
t3 = t3 * 1
t3 = t1 * t2
t1 = Format(t1, "#0")

t2 = Format(t2, "#,##0.00")
t3 = Format(t3, "#,##0.00")
 a = s1.[a65536].End(3).Row + 1

 
s1.Cells(a, "b") = CDate(TextBox1.Value)
s1.Cells(a, "c") = ComboBox1
s1.Cells(a, "d") = TextBox2.Text
s1.Cells(a, "e") = ComboBox2
s1.Cells(a, "f") = ComboBox3
s1.Cells(a, "g") = TextBox3.Text
s1.Cells(a, "h") = TextBox4.Text
s1.Cells(a, "ı") = t1
s1.Cells(a, "j") = t2
s1.Cells(a, "k") = t3
s1.Cells(a, "l") = TextBox8.Text

Range("A3:L10000").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:= _
        xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
         For sira = 1 To WorksheetFunction.CountA(Range("b3:b65536"))

Range("a" & sira + 2) = sira
Next

    
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    TextBox6.Text = ""
    TextBox7.Text = ""
    TextBox8.Text = ""
    ComboBox1 = ""
    ComboBox2 = ""
    ComboBox3 = ""
    
UserForm_Initialize
    
End Sub
 
Kırmızı satırı ilave ediniz.:cool:
Kod:
Private Sub CommandButton1_Click()
On Error Resume Next
Set s1 = Sheets("Veri")
TextBox1.Value = Format(TextBox1.Value, "dd.mm.yyyy")


t1 = CDbl(TextBox5)
t2 = CDbl(TextBox6)
t3 = CDbl(TextBox7)

t1 = t1 * 1
t2 = t2 * 1
t3 = t3 * 1
t3 = t1 * t2
t1 = Format(t1, "#0")

t2 = Format(t2, "#,##0.00")
t3 = Format(t3, "#,##0.00")
 a = s1.[a65536].End(3).Row + 1

 
s1.Cells(a, "b") = CDate(TextBox1.Value)
s1.Cells(a, "c") = ComboBox1
s1.Cells(a, "d") = TextBox2.Text
s1.Cells(a, "e") = ComboBox2
s1.Cells(a, "f") = ComboBox3
s1.Cells(a, "g") = TextBox3.Text
s1.Cells(a, "h") = TextBox4.Text
s1.Cells(a, "ı") = t1
s1.Cells(a, "j") = t2
s1.Cells(a, "k") = t3
s1.Cells(a, "l") = TextBox8.Text

Range("A3:L10000").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:= _
        xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
         For sira = 1 To WorksheetFunction.CountA(Range("b3:b65536"))

Range("a" & sira + 2) = sira
Next

    
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    TextBox6.Text = ""
    TextBox7.Text = ""
    TextBox8.Text = ""
    ComboBox1 = ""
    ComboBox2 = ""
    ComboBox3 = ""
[B][COLOR="Red"]Combobox1.clear  [/COLOR][/B]  
UserForm_Initialize
    
End Sub
 
Çok teşekkür ederim hocam ben clear komutunu değilde
Kod:
combobox1=empty
kodunu denemiştim ama olmamıştı şimdi sizizn gönderdiğiniz kod çalışıyor
 
Çok teşekkür ederim hocam ben clear komutunu değilde
Kod:
combobox1=empty
kodunu denemiştim ama olmamıştı şimdi sizizn gönderdiğiniz kod çalışıyor

Rica ederim.
İyi çalışmalar.:cool:
 
Geri
Üst