I've created a Userform, where I have a combobox and a textbox. My goal is after clicking on an element in the combo box it then shows the key, id or whatever was assigned.
This is how far I come:
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Item1", A
.AddItem "Item2", B
.AddItem "Item3", C
End With
End Sub
Private Sub ComboBox1_Change()
Me.TextBox1.Value = Me.ComboBox1.ListIndex
End Sub
This code works, but instead of letters I get numeric values from 0 upwards. I know this is due to the listindex property. But there must be a way to get letters correctly so that if I select Item1 in the ComboBox the letter A in the TextBox should pop up, if select Item2 then B should pop up and so on.
