• DİKKAT

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

Combobox rowsource 2 sütun olabilir mi?

Katılım
26 Kasım 2006
Mesajlar
234
Excel Vers. ve Dili
2010-2013 Türkçe
Kod:
ComboBox1.RowSource = "Parametreler!W2:X" & _
WorksheetFunction.CountA(Worksheets("Parametreler").Range("W1:X65536"))

Yukarıdaki gibi bir kod denedim sonuç başarısız. yapmak istediğim Combonun açılır listesine X ve W sütunundaki verileri çekmek. Mümkün değilse alternatif fikirlerde işimi görecektir. Teşekkür Ederim.
 
Kod:
ComboBox1.RowSource = "Parametreler!W2:X" & _
WorksheetFunction.CountA(Worksheets("Parametreler").Range("W1:X65536"))


Yukarıdaki gibi bir kod denedim sonuç başarısız. yapmak istediğim Combonun açılır listesine X ve W sütunundaki verileri çekmek. Mümkün değilse alternatif fikirlerde işimi görecektir. Teşekkür Ederim.
Buyurun.
Kod:
combobox1.columncount=2
 
yanıt

Bu şekil deneyebilirsiniz.
Kod:
Private Sub UserForm_Initialize()
Dim sat As Integer
Dim s As Integer
ComboBox1.ColumnCount = 2
For sat = 2 To Cells(Rows.Count, "w").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "w") & "     " & Cells(sat, "x")
        s = s + 1
Next
End Sub
 
Bu şekil deneyebilirsiniz.
Kod:
Private Sub UserForm_Initialize()
Dim sat As Integer
Dim s As Integer
ComboBox1.ColumnCount = 2
For sat = 2 To Cells(Rows.Count, "w").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "w") & "     " & Cells(sat, "x")
        s = s + 1
Next
End Sub

Bu kod ile her iki sutun veriside combobox içine birlikte çekilebiliyor. Ancak benim yapmak istediğim Combobox'a ayrı ayrı çekebilmek. yani "x" deki veriye tıkladığımda sadece "x" deki veri gelecek "w" daki gelmeyecek...
 
yanıt

Kod:
Private Sub CommandButton1_Click()
ComboBox1.Clear
For sat = 2 To Cells(Rows.Count, "w").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "w")
        s = s + 1
Next
End Sub
Private Sub CommandButton2_Click()
ComboBox1.Clear
For sat = 2 To Cells(Rows.Count, "x").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "x")
        s = s + 1
Next
End Sub
 

Ekli dosyalar

Kod:
Private Sub CommandButton1_Click()
ComboBox1.Clear
For sat = 2 To Cells(Rows.Count, "w").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "w")
        s = s + 1
Next
End Sub
Private Sub CommandButton2_Click()
ComboBox1.Clear
For sat = 2 To Cells(Rows.Count, "x").End(xlUp).Row
    ComboBox1.AddItem
        ComboBox1.List(s, 0) = Cells(sat, "x")
        s = s + 1
Next
End Sub

Teşekkür Ederim Ziya bey. Son derece güzel bir yöntem.
 
Geri
Üst