I have a userform with a 2 listboxes. One has a list of items, the other displays items from a sheet that is filtered based on what is selected in the first listbox.
All of that works correctly, except I have a problem with the highlighting on the first listbox.
The way is it supposed to work is that when an item is selected in the first listbox, the filtering code is run which fills the second listbox and also moves the selected item to the top position in the first listbox. After the item is added to the top and then removed from it's previous position, I set the listindex to 0 so the correct item (which is now at position 0) is once again selected. I do have code that keeps the click event from firing multiple times.
The problem is that the item that is highlighted in the listbox is whatever position that was clicked. I can't get the highlight to move to the top.
I put some debug code in and it seems that the listindex is indeed set to 0, but the highlight bar isn't in the right position. Why?
I found this code
Listbox refresh problem -- mysterious phantom highlighting
but that didn't solve my problem either.
Any ideas?
All of that works correctly, except I have a problem with the highlighting on the first listbox.
The way is it supposed to work is that when an item is selected in the first listbox, the filtering code is run which fills the second listbox and also moves the selected item to the top position in the first listbox. After the item is added to the top and then removed from it's previous position, I set the listindex to 0 so the correct item (which is now at position 0) is once again selected. I do have code that keeps the click event from firing multiple times.
The problem is that the item that is highlighted in the listbox is whatever position that was clicked. I can't get the highlight to move to the top.
I put some debug code in and it seems that the listindex is indeed set to 0, but the highlight bar isn't in the right position. Why?
I found this code
Listbox refresh problem -- mysterious phantom highlighting
but that didn't solve my problem either.
Any ideas?