Reputation: 265
I have a Form Control list box with multiple items.
I would like a certain cell on the worksheet to display the contents of the list box item the user selects and change if the user makes a different selection.
Upvotes: 1
Views: 13985
Reputation: 791
I guess you already know how to write to a cell:
Set TxtRng = ActiveWorkbook.Sheets("YourSheet").Range("A1")
TxtRng.Value = "Your Text Here"
And the following piece of code would go into your ListBoxChanged-Event, so the cell displays the new value every time a new value has been selected in the List Box.
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
SelectedItemText = ListBox1.List(i)
End If
Next i
'Set the value of the cell to the selected item.
TxtRng.Value = SelectedItemText
Hope this helps.
Upvotes: 1