+ Reply to Thread
Results 1 to 7 of 7

I need to code a button to save and update data from a user form into multiple worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    5

    I need to code a button to save and update data from a user form into multiple worksheets

    Hi,

    I am new to this site and have never really used vb before. I am trying to make a user form where the user can enter data that then gets saved (imported) into multiple sheets of the excel workbook. The user form has four tabs; three pertaining to independent contractors that are hired and one that pertains to the client and project info. The user can go in and search for a project by project number and the form will fill in the textboxes with the data that is saved out in the worksheets. I am trying to create a save button that will either add a new line of data if the project, client or contractors are new or overwrite the current data if the user changes an of the information. I originally had an export button and a separate update button but could never get the update button to work. I then decided to just have one save button. the code partially works but it takes a while to process and it doesn't complete the code that is there. I have no idea what I'm doing or what I'm doing wrong. Please help!!


    CES form - Copy.xlsm

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I need to code a button to save and update data from a user form into multiple workshe

    You are probably over complicating things

    Because you have not got enough knowledge to avoid the pit falls

    I will look at this for you and give you some pointers.


    1. First Pitfall never change the control names.

    That allows you to do cool things like

    Fill 30 Text boxes with the numbers 1 to 30

    For count = 1 to 30
    Me.controls("Textbox"&Count).text = count
    Next
    or

    Fill The 30 Text Boxes with the contents of row 1, A1 to AD1

    For count = 1 to 30
    Me.controls("Textbox"&Count).text = cells(1,count).value
    Next
    or

    Save The 30 Text Boxes to row 1, A1 to AD1

    For count = 1 to 30
     cells(1,count).value = Me.controls("Textbox"&Count).text
    Next
    2. Second Pitfall Number Your Text boxes in the order you want to save them.

    Your Numbering and Data are all over the place.

    It Just Makes it Harder to work with.
    Last edited by mehmetcik; 12-01-2015 at 05:53 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    11-12-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    5

    Re: I need to code a button to save and update data from a user form into multiple workshe

    Thank you for you quick response!

  4. #4
    Registered User
    Join Date
    11-12-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    5

    Re: I need to code a button to save and update data from a user form into multiple workshe

    I still don't know why my code isn't working for my save button. It won't go through all the code and sometimes it works in some examples but not in others. Is it interfering with other blocks of code? I'm so frustrated with this. Please help me if you can, I will be so grateful!!

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I need to code a button to save and update data from a user form into multiple workshe

    give me instructions on how to cause the error and i will clear it for you.

  6. #6
    Registered User
    Join Date
    11-12-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    5

    Re: I need to code a button to save and update data from a user form into multiple workshe

    Awesome! Thanks!

    Well, once you activate the user form and enter the necessary data the code is supposed to 1) check to see if this is a new project or an existing project; if it is new then the the project information gets added to a new row of the "Project Database" worksheet, if it is an existing project it is supposed to find the project (using the project number to search) and overwrite/update the data. 2) check to see if the client or any of the independent contractors are new or existing (the code uses the client number to search through the list of clients on the "clients" worksheet or it uses the contractors EIN/SSN to search for the contractors information), if it exists it should update the information in the corresponding worksheets ("Clients" or "contractors database") if it is a new client or contractor it is supposed to add the info to the next empty row. At the end of the process a message box should pop up that says "project x has been saved".

    when running certain examples the code will partially work, it doesn't give me any error messages or indicate to me where it stopped processing the code. for example, if I enter completely new information - new project number, new client or existing client, all new contractors - the code will work, but if some of the data is existing and some of the data is new it doesn't work. I can't figure out why. Maybe if you run it a few times and enter your own data and check the spreadsheets to see what worked and what didn't you would know what is happening. I just don't have the knowledge to know why it works sometimes and not others.

  7. #7
    Registered User
    Join Date
    11-12-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    5

    Re: I need to code a button to save and update data from a user form into multiple workshe

    I did notice that I left 'txt' in front of ICNumber, ICNumber2 and ICNumber3....it needs to be removed, didn't fix anything though. For example, the last line below, the txt needs to be removed

    Set wsCD = Sheets("Contractors Database")
    ICNumber = txtICNumber.Text
    lrCD = wsCD.Range("A" & Rows.Count).End(xlUp).Row
    For y2 = 2 To lrCD
    If wsCD.Cells(y2, 1).Text = txtICNumber Then

+ 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. User form with search and update function with multiple column/Data
    By onyony34 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-08-2015, 03:05 AM
  2. User Form Button to Save work Book
    By venkcris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2014, 12:01 AM
  3. Require VBA code to Get data from data table to user form using command button
    By Srikanth H N in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2014, 04:17 PM
  4. [SOLVED] Re: Please help for Excel User form send data for multiple worksheets
    By gopala in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2013, 04:08 AM
  5. Issues having more than one user update worksheets using VBA Form
    By llanusa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-15-2012, 04:26 PM
  6. [SOLVED] Making a user form button work to save data
    By Bigd29 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2012, 06:13 AM
  7. [SOLVED] Using Button on User Form to save Data to specific Cell??
    By DarnTootn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2006, 10:25 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