+ Reply to Thread
Results 1 to 15 of 15

Needed: VBA code to edit/update data (sample workbook attached)

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Needed: VBA code to edit/update data (sample workbook attached)

    Hello Excel Forum,

    I'm hoping one of you may be able to point me in the right direction. I've created a spreadsheet (DataCollectionForm.xlsm) that is used for coding play interactions. I've got two buttons with corresponding macros that allow me to clear the form or transfer data from the worksheet "EA - CodingForm" to the data table "EA - DataTable". I'm hoping someone can assist me with the appropriate VBA code to recall/edit/update previously entered data. In cell B2, I have a dropdown that shows the study ID's that have been previously recorded. If you select a study ID, I'd like the rest of the corresponding data that was previously entered to populate on the "EA - CodingForm".

    Any help would be greatly appreciated.

    Cheers,
    MileHigh_PhD

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Right click on the EA - Coding Form tab, choose view code and paste the code into that window.
    The code will run whenever you change the selection in the box. Check for accuracy because I just took the cells in your code where you pasted data into the data table and used them to put the data back. Then I restored your formulas with the total labels above them.

    Good Luck!!!


    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    Thanks for the help... Unfortunately, though, it is still not working for me. I've attached a copy DataCollectionForm.xlsm of the workbook with your code inserted into the
    EA - CodingForm worksheet. Please let me know if you have any suggestions.

    Thanks, again!

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Yeah, my question would be what do you mean by doesn't work? Is there a cell that has the wrong data, the code doesn't do anything?
    You are enabling macros? If it's not doing anything, then type something in a cell and run your clear program, or better yet I'm sending the file back to you populated. I opened the spreadsheet and changed the box to 444 and you can see the results, so what's wrong with what it's doing? Hopefully it's not a MAC issue but if your clear code is working I don't think it is. Let me know.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    It appears it may be working for you, as I was able to open the file you sent and see #444's data populated in the worksheet. However, if I select a different ID # from the dropdown, the data does not change in the EA - CodingForm worksheet. My Save & Clear buttons appear to work just fine. I am working off a mac, is there anything that needs to be different so it will work on both mac & pc?

    Thanks, again, for your continued help!
    -MileHigh_PhD

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Okay, please open this file and run the code by changing the drop down and pushing the button I put on the sheet.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    Thanks for all the help! It is now working after selecting from the dropdown and pushing the button. Is this just a mac thing, that doesn't recognize a change procedure?

    Another quick question, if I use my save button after editing the data, it saves it as a new record and does not update the existing record. Any chance you'd be able to help alter my save code to be able to add or update the record based off the subject ID?

  8. #8
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Geez let me have some more coffee. I saw your request at the bottom and I was responding with if I can't get past this first problem how can I help you with the other. I read your first line as it is "not" working, but now that I see "now", well then yes maybe I can help you. I have one other test I would like you to perform.

    Open the file below change the box to another number, don't push the button I just want you to change the box and if something happens let me know exactly what it was. Write down anything that comes up exactly as you see it.

    I'd be more than happy to help you with the other thing.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    I tried the revised file and do not see anything happening when I select a different StudyID from the dropdown in B2...

  10. #10
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    I'm not finding anything on the internet. The change event doesn't seem to be firing, so I guess you 'll have to live with a button. I'll let you format that and put it where you want on the sheet.

    So your request is if you recall data and change it, you want to overwrite the existing data on the other sheet, correct? Do you want to do this in all circumstances or do you want the option of creating a new record. If you want a new record I would recommend a way to have a different subject ID number than the first time, otherwise when you open the drop down list how would you know which one you want? You are going to see several and the previous code I wrote for you is going to pull up the first record with the number you choose.
    I'll start writing the code, if you want to fix that button however you want and repost that sheet I'll just add it to that sheet. The code I put into the sheet I posted needs to be removed because I ran it on my computer and it will just keep looping if it starts to work on your computer. I had to hit control break to get it to stop.


    Quote Originally Posted by MileHigh_PhD View Post
    Hi skywriter,

    I tried the revised file and do not see anything happening when I select a different StudyID from the dropdown in B2...

  11. #11
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    Attached is the spreadsheet with the button formatted how I'd like it in cell A2. The subject ID will be a unique number, so I think overwriting the existing data will be just fine. Please let me know if you have any questions.

    DataCollectionForm2222015R1.xlsm

    Thanks!

  12. #12
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Test this by changing some recalled data and by adding a new record and make sure they all work.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi skywriter,

    It's working great. Thanks again for all your help!

  14. #14
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    My pleasure.

  15. #15
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Needed: VBA code to edit/update data (sample workbook attached)

    Hi Skywriter

    Sorry to chip in here, the data being collected and updated is from one sheet (EA - CodingForm). Is it possible to collect data for the database table from other sheets also, and to be repopulated again?

    if so how would code this?

+ 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. How to reformat data - Sample input and outputs are attached
    By Palraj in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-12-2015, 07:22 AM
  2. FIFO-LIFO UDF function not working if DataRange are apart from each other
    By Par in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2014, 06:02 PM
  3. [SOLVED] Urgent Help Needed To auto populate my form using formulas (With sample attached)
    By pringle1987 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-15-2013, 11:15 PM
  4. Combining If and Lookup for Complicated Data (Sample is attached)
    By than_k22 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-15-2010, 01:13 PM
  5. Replies: 0
    Last Post: 07-21-2009, 05:21 AM

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