Search edit and update using userforms

  • Hi,

    I really need some help. I have a spreadsheet full of sensitive data so I cant upload it here so I'll explain in detail what I need help with.

    I have created a userform that has multiple text and combo boxes that I need to populate from data in the workbook using a reference number search.

    Here's what I have:

    a textbox and a search button

    12 Text Boxes

    8 Combo Boxes

    2 Check Boxes

    I would like to type in a reference number, click search and have the relevant data from the spreadsheet populate the textboxes/combo boxes and then be able to amend the data, click the update button and have the new data overtype the old data within the spreadsheet.

    I dont even know if it's possible. I've spent around 5 hours this morning on google and I'm losing the will to live lol.



  • Hiya,

    Just a quick question. I'm working through the code to make it apply to my sheet and im having an issue.

    Everything is mostly working. The search brings up the required information and I can amend as needed. But it's no longer editing the sheet when I click the save.

    Here's the code. Can you take another quick look?

  • DariaLoveborn

    Please read the Forum Rules to learn how to use the Forum Correctly and get the best results. I have added Code Tags this time for you.

  • There's a much simpler and probably faster way to do this.

    Change the Search TextBox for a ComboBox, this eliminates the possibility of entering an incorrect ID.

    Load the data into the ComboBox. Then when an ID is selected the other controls are loaded.

    Also, writing back to the correct row is simplified.

  • Not many people realise you can add all the data into a combobox and refer to it in the code. I have made the amendments to the uplifted data in the past then simply written everything back to the data sheet.

  • I'm having a lot of problems trying to transfer the code to my sheet. I've got a total of 19 textboxes and everytime I try to transfer the code, it'll work a few times but if i leave it for too long, when I come back to it, it starts throwing up errors.

    I'm really not sure what I'm doing wrong here.

    Below is the code I'm using. But i'm getting runtime error 9 everytime I click the load form button.

  • There's two userforms. I don't think that you need two, one can be used to add or edit.

    Let me know which one to use, I'm thinking the add patient form, and I'll update your code.