2 sütunlu bir comboBox' ta istenilen değeri getirme

Katılım
29 Ocak 2024
Mesajlar
76
Excel Vers. ve Dili
Office 2016
Merhaba,
Userform içinde 2 sütunlu bir comboBox (cmBox) mevcut,

sütunlardaki veriler aşağudaki şekilde oldun;

1 2

1 A
2 B
3 C
4 D

5 E

burada combobox değerini "4 D" olan satırı nasıl gösterebiliriz?
cmBox.value= 4 D

şeklinde görünmesi nasıl sağlanabilir?

yardımlarınız için şimdiden teşekkürler,
iyi Çalışmalar.
 

hamitcan

Uzman
Uzman
Katılım
1 Temmuz 2004
Mesajlar
7,699
Excel Vers. ve Dili
Excel 2019 Türkçe
Böyle bir şey mi ?
Kod:
Private Sub ComboBox1_Click()
x = ComboBox1.ListIndex
 ComboBox1.Value = ComboBox1.List(x, 0) & " " & ComboBox1.List(x, 1)
End Sub

Private Sub UserForm_Initialize()
    ComboBox1.RowSource = "A1:B5"
    ComboBox1.Value = ComboBox1.List(3, 0) & " " & ComboBox1.List(3, 1)
End Sub
 
Katılım
29 Ocak 2024
Mesajlar
76
Excel Vers. ve Dili
Office 2016
Böyle bir şey mi ?
Kod:
Private Sub ComboBox1_Click()
x = ComboBox1.ListIndex
ComboBox1.Value = ComboBox1.List(x, 0) & " " & ComboBox1.List(x, 1)
End Sub

Private Sub UserForm_Initialize()
    ComboBox1.RowSource = "A1:B5"
    ComboBox1.Value = ComboBox1.List(3, 0) & " " & ComboBox1.List(3, 1)
End Sub
Hamit Hocam teşekkürler,
List(3, 0)

burada 4 D ifadesin 3. sırada olduğunu biliyoruz, eğer sıra numarasını bilmiyorsak, 4 yada D ifadelerini kullanarak combobox' a değerleri getirmek

iyi Çalışmalar.
 

hamitcan

Uzman
Uzman
Katılım
1 Temmuz 2004
Mesajlar
7,699
Excel Vers. ve Dili
Excel 2019 Türkçe
Böyle dener misiniz ?
Kod:
Private Sub UserForm_Initialize()
    ComboBox1.RowSource = "A1:B5"
    For i = 0 To ComboBox1.ListCount - 1
        If ComboBox1.List(i, 0) = 4 Then ComboBox1.Value = ComboBox1.List(i, 0) & " " & ComboBox1.List(i, 1)
    Next
End Sub
 
Üst