Title: Refreshing a Listbox and Returning to the Original Line
Tags: excel;vba;listbox
Question: I have a listbox which is loaded with rows of information from a selected worksheet. Selecting a line from the listbox allows me to update information on a userform and save it back to the worksheet. I would like to refresh the listbox with the new information and go back to the line I was working on without having to scroll down from the top each time I refresh the listbox. Is it possible to save the current listbox line and return to it after refreshing the listbox?

Comment: Please show what you have tried.

Comment: For the project I'm working on the number of rows in the listbox won't change. It seems like saving the current position of the pointer, refreshing the listbox and then setting the index to the saved number would do the trick. I'm just not sure how you write code in VBA to do that.

Comment: Yes, it's possible, but how easy it is depends if the number of items in the listbox is going to change or not. https://docs.microsoft.com/en-us/office/vba/api/access.listbox.listindex



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:01/16/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<excel><vba><listbox>', 'Title': 'Refreshing a Listbox and Returning to the Original Line', 'ViewCount': 79, 'id': 59779452, 'user_AboutMe': None, 'user_AccountId': 11781467.0, 'user_DisplayName': 'sjack', 'user_Reputation': 1.0, 'user_Views': 1.0, 'user_id': 8620843.0}}