Michael Simpson
Board Regular
- Joined
- Jun 21, 2010
- Messages
- 232
I have the following code in my change event for a listbox
Now, obviously, all this does is to loop through the items in the listbox and indicate whether they've been selected or not.
What I would like to do is to be able to capture the entry in the listbox that started the change event.
Basically, I've populated the listbox with customers on a sheet. What I would like to do is to change the background colour for the sheet rows based on the items the user selects from the listbox. Assume there are 3 customers. If they select customer 1 from the listbox, then that customer row on the sheet will be coloured green. If they deselect customer 1, the colouring is removed.
I'm assuming my code needs to determine/get the customer's name from the item just (de)selected from the listbox so as to be able to determine which row on the sheet needs to be changed.
Any good suggestions appreciated.
Code:
Private Sub Customer_listbox_Change()
Dim counter As Integer
For counter = 1 To Customer_ListBox.ListCount Step 1
If Me.Customer_ListBox.Selected(counter - 1) = True Then 'selected method has 0 base
MsgBox ("Selected item")
Else
MsgBox ("DESelected item")
End If
Next counter
End Sub
What I would like to do is to be able to capture the entry in the listbox that started the change event.
Basically, I've populated the listbox with customers on a sheet. What I would like to do is to change the background colour for the sheet rows based on the items the user selects from the listbox. Assume there are 3 customers. If they select customer 1 from the listbox, then that customer row on the sheet will be coloured green. If they deselect customer 1, the colouring is removed.
I'm assuming my code needs to determine/get the customer's name from the item just (de)selected from the listbox so as to be able to determine which row on the sheet needs to be changed.
Any good suggestions appreciated.