+ Reply to Thread
Results 1 to 8 of 8

Update a row in a different spreadsheet using VBA userform

  1. #1
    Registered User
    Join Date
    02-24-2020
    Location
    Hertfordshire, England
    MS-Off Ver
    2016
    Posts
    4

    Update a row in a different spreadsheet using VBA userform

    Hello,

    I am brand new to this forum and VBA.

    I have recently created two forms in my workbook:

    1. one to add in a new customer to the end of the data - this one works and is good for what I need (green button in my attachment)
    2. one that allows me to search data, based on school name, and display information that is contained in the worksheet - works but I would like to add an update button (red button in my attachment)

    In the user form that searches the data (red button) I would like to be able to change any of the required fields - press an 'update' button - and the data would be replaced in the relevant cell in the "Data" sheet (based on the school name - this is unique in each row).

    I have been searching for a few days and tried various ways to get it to work; although as I am new to this I don't understand where I am going wrong and have not been able to find a solution.

    I would greatly appreciate if someone had an answer to my problem (I just need the code to make it work if possible); even if it is that it can't be done - at least I can stop looking!

    I have attached what I have so far.

    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Update a row in a different spreadsheet using VBA userform

    I don't really understand the code in your updateButton routine (ignoring the fact that you don't actually have a button by that name). It tries to populate the Data sheet with the values of controls in the other form, which presumably isn't loaded at that point, so they will all be blank.
    Rory

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Update a row in a different spreadsheet using VBA userform

    Try the attached file. I have added an "Update Data" button to the Customer Order Tracking userform. First search for the school, change the desired data and click the "Update Data" button.
    Attached Files Attached Files
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Registered User
    Join Date
    02-24-2020
    Location
    Hertfordshire, England
    MS-Off Ver
    2016
    Posts
    4

    Re: Update a row in a different spreadsheet using VBA userform

    Quote Originally Posted by rorya View Post
    I don't really understand the code in your updateButton routine (ignoring the fact that you don't actually have a button by that name). It tries to populate the Data sheet with the values of controls in the other form, which presumably isn't loaded at that point, so they will all be blank.
    Hi rorya,

    Thanks for the reply. As I am brand new to this I really messed up what I was doing and thought it would be a variant on the code that worked for me in the other form .

    I thought I deleted everything as it was not working; including the button!

    Thanks

  5. #5
    Registered User
    Join Date
    02-24-2020
    Location
    Hertfordshire, England
    MS-Off Ver
    2016
    Posts
    4

    Re: Update a row in a different spreadsheet using VBA userform

    Quote Originally Posted by Mumps1 View Post
    Try the attached file. I have added an "Update Data" button to the Customer Order Tracking userform. First search for the school, change the desired data and click the "Update Data" button.
    OMG you're amazing!

    It looks so logical once you see it. Thank you so much for you quick response and fixing it - exactly what I needed.

    I love it

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Update a row in a different spreadsheet using VBA userform

    You are very welcome.

  7. #7
    Registered User
    Join Date
    02-24-2020
    Location
    Hertfordshire, England
    MS-Off Ver
    2016
    Posts
    4
    Quote Originally Posted by Mumps1 View Post
    You are very welcome.
    It works beautifully and i have been using loads over the last couple of days with no problems or errors.

    You're a saviour, thank you.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Update a row in a different spreadsheet using VBA userform

    My pleasure.

+ 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. Update Information on Spreadsheet using a UserForm
    By Touch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 01:42 PM
  2. Update Information on Spreadsheet using a UserForm
    By Touch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 11:11 AM
  3. Replies: 20
    Last Post: 11-15-2012, 09:32 PM
  4. Update an open userform with spreadsheet data
    By rawcode in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2012, 12:45 PM
  5. VBA Userform to be used by multiple users to update spreadsheet
    By Sasha28 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2012, 09:46 PM
  6. edit data in userform and update spreadsheet
    By nunans in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 04:44 AM
  7. Replies: 4
    Last Post: 08-27-2007, 01:51 AM

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