BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I have a listbox that is set to only select one record at a time. What happens though, is when I click a second time, the first record stays highlighted (as well as the second) until I click a third record. Then the first row is o longer highlighted, but the second record and third are. Clicking a fourth removes the second but leaves the third and fourth highlighted, etc.
The following is the code I am using but what would I put into the front of the code to basically remove selection? I tried listbox.selected(x).clear, etc., but nothing has worked?
The following is the code I am using but what would I put into the front of the code to basically remove selection? I tried listbox.selected(x).clear, etc., but nothing has worked?
Code:
For x = 0 To UserForm1.ListBox1.ListCount - 1
If UserForm1.ListBox1.Selected(x) Then
MsgBox UserForm1.ListBox1.Value
End If
Next