Avatar of Katie Dee
Katie Dee

asked on 

Search command button on Excel Userform to return a list of results

I have built a userform that has three command buttons - Search, Save and Add New Record, Save and Exit.  I am struggling with the Search function.  The challenge is that there are 33 fields, but only five would be suitable to search by:  Staff Name, Caller First and Last Name, Recipient First and Last name.  Since the records do not have a unique identifier, the end user should be able to search by any of those five fields and get a returned list of matches.  

If the user does not find a result they are looking for, they should be able to "X" down that list and return to the userform.  I need to figure out a way that when they "X" it down, it will have cleared out the search data and display only a blank userform.

If the user clicks on a name in the list of results, it should then open that record with all the associated data into the userform. I'm thinking I should create another Userform just for this function so the code for the Save and Exit Button as well as the Save and Add New Record button will replace the record on the worksheet instead of adding another record to the next blank row.  I have read through every possible code I can find on the web because I'm not a programmer and couldn't possibly figure this out on my own.  I do have the other two buttons working though, thanks to the web.

Can anyone help get me started on the Search button programming so that it returns the results in a list?  I'm thinking there is code out there that will tell me how to get the record to display on the userform as well as a code to "X" down the list of results.
VBAMicrosoft Excel

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon