Creating search and update command buttons in a userform [Solved/Closed]

Ask a question janb 1Posts Friday June 28, 2013Registration date June 28, 2013 Last seen - Last answered on May 27, 2017 at 10:02 AM by Ting
I have created a userform for inputing new records in an Excel spreadsheet. I have written the code for the Save Record and Close Form command buttons already using VBA code.

Now I want to add a command button that will perform a search of a specific field (LName) in all records.

I also want to add a button that will update a record that has been modified.

I'm not sure what code to use.

Thanks for your time.
plus moins
Hi ,

I made an advanced userform example .
Really it's many features .
- Data Adding
- Data Delition
- Data Update
- Searching with The Userform
- Progress Bar Feature
- Scrolling the Listbox with Spin Buttons
- Next ,Previous ,First ,Last Recording Buttons
- Sheet Hide / Show Features with Toggle Button

Was this answer helpful?  
Bogs30 1Posts Thursday July 28, 2016Registration date July 28, 2016 Last seen - Jul 28, 2016 at 11:01 PM
Hi, is it possible to send me this file? Thank you
PS-C21H 1Posts Tuesday August 16, 2016Registration date August 16, 2016 Last seen - Aug 16, 2016 at 02:46 PM
This is wonderful! Exactly what I am needing. May I also have a copy of the file?
Thank you!
DOnzkie- Sep 5, 2016 at 08:47 PM
i can have that code..
Chen- Sep 4, 2016 at 02:06 PM
Hi, Can you send it to ***@***. thanks ! I will really appreaciate it.
Ting- May 27, 2017 at 10:02 AM
Thank you very much. May I have the code please? Please send it to ***@***
plus moins
Is it possible to download the file pictured at the top? I would very much appreciate being able to study the code.

It is easily possible I am missing something obvious to do so (I'm getting old...)

plus moins
I have uploaded the file to this link


On the worksheet tab named Input Master there is a button that will take you to the Input Form at the bottom of the Form there are 4 command buttons.
Add Record - is working fine and when you fill in the form and click the button it adds a new record to the Input Master worksheet on the next available row then closes the form
Search Record - is not programmed - I would like this button when clicked to open a search function that would allow you to find records that already exist
Update Record - is not programmed - I would like to be able to update a record that already exists by clicking this button - I do not want to create a new record when this is clicked just update the existing record with any changes/additional information that was input on the form
Close Form - is working fine when clicked it closes the form
plus moins
Hi jbooth,

Hopefully you will like the following solution:

Open userform, enter data in userform, click on "Find Record".
A sheet will be made visible with all the records with the same ClientLN or Coach.

On this sheet (Search results) there are 2 buttons: Update and Cancel.
Cancel: Remove search results, hide sheet and return to "Input master" sheet.

Update: First select the cell or row that you wish to update (this is also what the button tells you) and click the "Update" button.
A message box appears if you didn't select a valid record.
A message box appears displaying the selected record and the record initially entered in the userform.
This is to confirm the update action. So either click on Cancel to stay on sheet and possibly choose another record to replace or click on OK. This will update (basically replace) the record on the "Input Master" sheet.

The only way to leave the "Search results" sheet is to use the buttons.

Note that the "Update" button is fully called:
Select row and hit this button to update record in Input Master sheet.
Note that the "Cancel" button is fully called:
Cancel search action.
Finally note that the "Update Record" button on the userform lost it's intended purpose and can be removed if you choose to work with this solution.

Here is your file:

Although it is not exactly what you asked, I think that it works pretty nicely.

Best regards,
plus moins
Hi Janb,

Could you upload your workbook to a filesharing site like or for better understanding of your query?

Also be as specific as you can as to what you want to accomplish.

Best regards,
plus moins
Hi jbooth,

Search Record - When does a record already exist? When all the cells column A:S are the same as another row?
Just checking in case you have other thoughts.
How do you see this working? Highlight duplicates, Delete duplicates, ....
Do you want a general search of the sheet or search for the values entered in the userform?

Update Record - How do you visualize this. Do you want users to input a row number and then replace that row with the data entered in the userform? Or ...

Best regards,
jbooth- Jul 9, 2013 at 12:05 PM
The Search function should search for any records using the ClientLN or Coach as a search parameter. Where more than one match is made there should be an opportunity to scroll through the matching records until you find the one you are looking for.

The Update function should only work after you have searched for and found an existing record that you want to update (make changes to). Once you have made the changes and clicked Update it should replace the existing record with one that includes the updated information.

Thanks for getting back to me. I hope this is clearer.

TrowaD 2286Posts Sunday September 12, 2010Registration date ContributorStatus November 7, 2017 Last seen - Jul 11, 2013 at 11:38 AM
Hi jbooth,

Working on solution.
Need some time though (don't have much spare time at the moment).
I will get back to you next week.

Best regards,
DOnzkie- Sep 5, 2016 at 08:55 PM
Hai Janb

Can you show me the code to create that userform because It really help my Internship.
jbooth- Jul 11, 2013 at 11:57 AM
Thanks I appreciate your help.

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!