+ Reply to Thread
Results 1 to 10 of 10

Edit and delete data in a table with a userform

  1. #1
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Edit and delete data in a table with a userform

    Hi community,

    I am in despair.
    I have an Excel file with 2 tables called:
    1.) Staff
    2.) Managers
    Headers are ID, First Name, Last Name, Salary.

    I have a code to add a new entry to the table and it works fine.
    But I just can't figure out how to search, edit and delete an entry.
    What I would like to have is, when I enter an ID in TextBox1 it will auto-populate First Name, Last Name and Salary.
    If I select any textbox and change the value in it and press Edit, it will update the values in the table also.
    I would also like to have a delete entry button, which would delete an entry by searching for the ID.
    Any help would be fantastic.
    Thank you so much.
    Attached Files Attached Files
    Last edited by frankytheman; 07-28-2020 at 02:22 PM.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Edit and delete data in a table with a userform

    I would think...This is all you require...For Now...Your requirement might change...

    Please note there is no error code incorporated should you not select Table...etc etc
    One button for both edit and add...
    Select Table from ComboBox
    Enter Id...If it exists it will populate TextBoxes...
    Make changes and press button...

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    For newly created Delete Button...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 07-28-2020 at 03:55 PM. Reason: Uploaded File
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Edit and delete data in a table with a userform

    How about:

    Please Login or Register  to view this content.
    Edit: Should have refreshed... since Sintek replied while I coded, oops.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Edit and delete data in a table with a userform

    Edit: Should have refreshed... since Sintek replied while I coded, oops.
    @ Arkadi...Not at all...options...so many options...That's how we learn...

  5. #5
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Edit and delete data in a table with a userform

    Hi sintek, that works great. Thank you so much.

    Hi arkadi, thank you. Works great, too. Do you also have the code how to delete an entry?
    I have to adapt it to the real workbook, and the setup there is a bit different.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Edit and delete data in a table with a userform

    Glad I could help...Tx for rep..PS, I uploaded a new sample incorporating code in case your Table is empty...

  7. #7
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Edit and delete data in a table with a userform

    Hi sintek,

    I get an error when the ID is not numeric, forgot to mention that the ID might be alphanumeric, eg. AL200

    Please Login or Register  to view this content.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Edit and delete data in a table with a userform

    Here you go...
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Edit and delete data in a table with a userform

    Sintek, you are a EXCEL GOD!!! Thank you so much. Hope I will have the same skills like you one day.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Edit and delete data in a table with a userform

    Nope...I too am still learning every day...This Forum and its members are great Tutors...Happy Coding...
    You will have to incorporate code that clears the Text Boxes after execution...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] UserForm to search, edit, add and delete data
    By Kinjal Doshi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-02-2023, 04:40 PM
  2. Add/edit/delete records userform
    By kryt0n in forum Excel General
    Replies: 7
    Last Post: 09-10-2018, 11:49 AM
  3. Edit/Delete data rows using VBA / Userform
    By BigPaulMc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2015, 05:17 PM
  4. UserForm : i need a userform to add data, delete data, edit data
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-08-2014, 01:59 AM
  5. [SOLVED] UserForm for Edit or delete an order
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-18-2013, 02:06 PM
  6. Userform Buttons to Delete or Edit existing data
    By rach3lmclark in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2013, 11:53 AM
  7. [SOLVED] Userform Add, Edit, Delete
    By jonjmortimer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2012, 08:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1