I have a two column listbox on a user form.
Two of my command buttons change the value in the second column for the item selected. The value can be empty (null, blank, etc.) or a "1".
The method I'm using to populate the listbox makes it so that value change is not automatically seen, so after a change is made I've added code for the listbox to repopulate so the chanage can be seen.
Repopulating it shows the value changed to, or from, a "1", but the listbox would always return to the top of the list after it was repopulated. This effectively makes you lose track of where you were in the list.
My next step was to remember the the ListIndex value for the item selected and then after the listbox was repopulated I set the listbox ListIndex value to that previous value.
That works fine, as far as if I there are 100 items on my list, and I changed item number 75, it will reselect that same item number 75, but it is always the very bottom of the window.
In other words, lets say item number 75 was was in the very middle of the visible listbox window when I selected it. So you could see items number 60 though 90 visible in the window. After I repopulate the ListBox and reset the ListIndex number, you will see item number 75 selected, but it will be at the very bottom of the ListBox window and in the window you will see item numbers 45 through 75, instead of item numbers 60 through 90.
I'd like to find a way to set the listbox to scroll to the very same position it was in before I repopulated it, so the user doesn't even know I've repopulated the ListBox. All I want them to see is that value in the second column to chanage to, or from a "1".
I've searched for hours for a solution and the closest I've come is the Userform Scroll event, but that does not seem to apply to a ListBox on a user form.
Is it possible to remember the scroll position of a ListBox and then reset the ListBox to that same position after it is repopulated?
Bookmarks