• DİKKAT

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

comboBox üzerindeki verilerin alfabetik gelmesi

Katılım
24 Şubat 2009
Mesajlar
1,077
Excel Vers. ve Dili
2016
Merhaba arkadaşlar; Aşağıdaki kodla C sütununda bulanan veriler tek olarak ComboBox1 üzerine geliyor;

Private Sub UserForm_Initialize()

For x = 2 To Cells(65536, 3).End(xlUp).Row
If WorksheetFunction.CountIf(Range("C2:C" & x), Cells(x, 3)) = 1 Then
ComboBox1.AddItem Cells(x, 3).Value
End If
End Sub

isteğim, bu verilerin birde tek ve Alfabetik gelmesini istiyorum, yardımcı olacaak herkese teşekkürler.
 
Merhaba,
Aşağıdaki şekilde dener misiniz?
Kod:
Private Sub UserForm_Initialize()
    For X = 2 To Cells(65536, 3).End(xlUp).Row
        If WorksheetFunction.CountIf(Range("C2:C" & X), Cells(X, 3)) = 1 Then
        ComboBox1.AddItem Cells(X, 3).Value
        End If
    Next
    For i = 0 To ComboBox1.ListCount - 2
        For j = i + 1 To ComboBox1.ListCount - 1
            If StrComp(ComboBox1.List(i, 0), ComboBox1.List(j, 0), vbTextCompare) = 1 Then
                X = ComboBox1.List(i, 0)
                ComboBox1.List(i, 0) = ComboBox1.List(j, 0)
                ComboBox1.List(j, 0) = X
            End If
        Next j
    Next i
End Sub
 
üstadım kusura bakma bu combo iki tane idi yani
For X = 2 To Cells(65536, 3).End(xlUp).Row
If WorksheetFunction.CountIf(Range("C2:C" & X), Cells(X, 3)) = 1 Then
ComboBox1.AddItem Cells(X, 3).Value
End If

If WorksheetFunction.CountIf(Range("I2:I" & X), Cells(X, 9)) = 1 Then
ComboBox2.AddItem Cells(X, 9).Value
End If

ikincisini yazamadım, buna da zahmet olmazsa bakarmısın
 
Merhaba,
Aşağıdaki kodu dener misiniz?
Kod:
Private Sub UserForm_Initialize()
    For X = 2 To Cells(65536, 3).End(xlUp).Row
        If WorksheetFunction.CountIf(Range("C2:C" & X), Cells(X, 3)) = 1 Then
        ComboBox1.AddItem Cells(X, 3).Value
        End If
        If WorksheetFunction.CountIf(Range("I2:I" & X), Cells(X, 9)) = 1 Then
        ComboBox2.AddItem Cells(X, 9).Value
        End If
    Next
For k = 1 To 2
For i = 0 To Controls("ComboBox" & k).ListCount - 2
    For j = i + 1 To Controls("ComboBox" & k).ListCount - 1
        If StrComp(Controls("ComboBox" & k).List(i, 0), Controls("ComboBox" & k).List(j, 0), vbTextCompare) = 1 Then
            X = Controls("ComboBox" & k).List(i, 0)
            Controls("ComboBox" & k).List(i, 0) = Controls("ComboBox" & k).List(j, 0)
            Controls("ComboBox" & k).List(j, 0) = X
        End If
    Next j
Next i
Next k
End Sub
 
Merhaba,
Aşağıdaki kodu dener misiniz?
Kod:
Private Sub UserForm_Initialize()
    For X = 2 To Cells(65536, 3).End(xlUp).Row
        If WorksheetFunction.CountIf(Range("C2:C" & X), Cells(X, 3)) = 1 Then
        ComboBox1.AddItem Cells(X, 3).Value
        End If
        If WorksheetFunction.CountIf(Range("I2:I" & X), Cells(X, 9)) = 1 Then
        ComboBox2.AddItem Cells(X, 9).Value
        End If
    Next
For k = 1 To 2
For i = 0 To Controls("ComboBox" & k).ListCount - 2
    For j = i + 1 To Controls("ComboBox" & k).ListCount - 1
        If StrComp(Controls("ComboBox" & k).List(i, 0), Controls("ComboBox" & k).List(j, 0), vbTextCompare) = 1 Then
            X = Controls("ComboBox" & k).List(i, 0)
            Controls("ComboBox" & k).List(i, 0) = Controls("ComboBox" & k).List(j, 0)
            Controls("ComboBox" & k).List(j, 0) = X
        End If
    Next j
Next i
Next k
End Sub

Merhaba arkadaşlar Sayın DEDE'nin hazırlamış olduğu kodu ekli dosyamdaki Userform1 üzerinde bulunan ComboBoxlara uygulayamadım buna bir bakar mısınız. Teşekkürler
 

Ekli dosyalar

Merhaba,
Aşağıdaki şekilde dener misiniz?
Mevcut kodunuzda fazladan Next ifadesi var onu silmelisiniz.
Kod:
    For X = 2 To Cells(65536, 3).End(xlUp).Row
        If WorksheetFunction.CountIf(Range("C2:C" & X), Cells(X, 3)) = 1 Then
        ComboBox1.AddItem Cells(X, 3).Value
        End If
        If WorksheetFunction.CountIf(Range("I2:I" & X), Cells(X, 9)) = 1 Then
        ComboBox2.AddItem Cells(X, 9).Value
        End If
    Next
    
    Dim k, i, j, w
    
For k = 1 To 2
For i = 0 To Controls("ComboBox" & k).ListCount - 2
    For j = i + 1 To Controls("ComboBox" & k).ListCount - 1
        If StrComp(Controls("ComboBox" & k).List(i, 0), Controls("ComboBox" & k).List(j, 0), vbTextCompare) = 1 Then
           w = Controls("ComboBox" & k).List(i, 0)
            Controls("ComboBox" & k).List(i, 0) = Controls("ComboBox" & k).List(j, 0)
            Controls("ComboBox" & k).List(j, 0) = w
        End If
    Next j
    Next i
    Next k
 
Merhaba,

Alternatif olarak ekteki örnek dosyayı inceleyiniz.
 

Ekli dosyalar

Korhan bey, benimde bir problemim var yardımcı olursanız sevinirim.
Combobox rowsource ile excell sayfamdan değer sütunu atadım, formum çalışırken combobox içindeki bana lazım olan değer yoksa comboboxa yazıdıktan sonra comboboxtan çıkarken yeni yazdığım değeri kaydedilip kaydedilmeyeceğini sorarak excell deki değer sütununun sonuna eklemesini istiyorum, combobox'ın Exit özelliğine gerekli formülleri yazdım ancak seçtiğim değer sütunda var olmasına rağmen çıkışta mükerrer kayıt yapıyor. Bu işlerde çok acemiyim yardımcı olursanız sevinirim.
 
Geri
Üst