+ Reply to Thread
Results 1 to 8 of 8

Userforms - find, retrieve and update information

  1. #1
    Registered User
    Join Date
    06-08-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Post Userforms - find, retrieve and update information

    Hi,

    I'm new to this forum, but have a little knowledge of VBA/Macros. I have created a userform to enter information into an excel worksheet.

    I have also created a second smaller userform to enter an ID number (which is generated when the first userform is submitted) which I now want to programme to search and find the ID and then repopulate the first userform with the information already submitted. I need to be able to amend it and then submit the form again - overwriting the existing information for that record.

    I've searched numerous sites, and have tried to decipher some existing code, but I'm not winning. Any ideas? I have attached the workbook I am working on.

    Many thanks in advance
    Jo
    Attached Files Attached Files

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Userforms - find, retrieve and update information

    This is from an old post, but might be helpful
    http://msdn.microsoft.com/en-us/libr...uildingawizard
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    06-08-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: Userforms - find, retrieve and update information

    This page doesn't exist any more - but thanks anyway.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Userforms - find, retrieve and update information

    So, how are they going to identify the record they want to edit?

    Will they have the ID in hand, ready to enter it when prompted?


    ---
    Would seem like all you would need to do is recall the entry form, refill the values (like a reverse of what you have in the current code - instead of going from the form objects to the worksheet - turn it around).

    BUT! you'll need a way of letting the logic know, when the user presses submit - don't blindly create a new record, but update the existing one.


    What you might try is just including a named_formula to hold that value when they press the "edit/amend" button.

    Logic would then be:

    *Press button.
    *Prompt user for the ID with an input box (capture the response and send it to the named formula cell).
    *Use a range.find() method in the VBA to locate that record.
    *Reverse copy the values in the record to the form.
    *Show the form.

    Now they do what ever they want. When they press "submit"...

    *Your code checks to see if the ID cell is blank (if it is, do what you were already doing)
    ** If not blank, then this is an edit/amend situation:

    *Instead of finding the next blank row (which you were doing for new record) - use a Range.FInd() method to locate the stored value for the ID.
    *Update the record - shove data from form to worksheet as per usual.

    *FLUSH THE ID - don't forget to blank out that 'id holder' cell! Otherwise you will always think you are editing something.


    ALSO! Don't loop to find the next row. Use a single line like this:


    i = activesheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    Last edited by GeneralDisarray; 07-07-2015 at 10:48 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Userforms - find, retrieve and update information

    Odd, the link works from the original post, so here is a link to the original post, then click the link in the last post'
    http://www.excelforum.com/excel-prog...nd-update.html
    Last edited by gmr4evr1; 07-07-2015 at 10:39 AM. Reason: Corrected typo

  6. #6
    Registered User
    Join Date
    06-08-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: Userforms - find, retrieve and update information

    There is a macro that allows them to check the information they have input - if they identify one that is not quite right, they will have the ID number in the pivot table to reference.

  7. #7
    Registered User
    Join Date
    06-08-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: Userforms - find, retrieve and update information

    Quote Originally Posted by gmr4evr1 View Post
    Odd, the link works from the original post, so here is a link to the original post, then click the link in the last post'
    http://www.excelforum.com/excel-prog...nd-update.html
    Thanks - the link works now.

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Userforms - find, retrieve and update information

    No problem, hope it works for you.

+ 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. Userforms - Unable to get UPDATE button to work
    By Kirstie1991 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2015, 04:31 PM
  2. Retrieve information from website using VBA
    By kwaldersen in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-11-2013, 03:04 PM
  3. [SOLVED] Can I use userforms to find and update?
    By ricku87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2013, 10:21 AM
  4. Search and update spreadsheet data using Userforms
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2012, 11:42 AM
  5. retrieve information
    By just1creation in forum Excel General
    Replies: 1
    Last Post: 10-26-2006, 02:46 PM

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