+ Reply to Thread
Results 1 to 15 of 15

[SOLVED] userform not adding data to worksheet

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    [SOLVED] userform not adding data to worksheet

    I've searched on here, but cannot find anything that answers my question. I have a userform built and the debugger says everything is ok, but when I enter data and click the add record button, nothing happens. I have 35 fields to populate with a number value and one field to populate with a month (using a combobox). I want to enter my data, click the Add Record button and have tha data added to the worksheet and have the userform cleared for the next entry. Below is my code, what have I missed?

    Please Login or Register  to view this content.
    Last edited by argentraven; 05-07-2010 at 07:20 PM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: userform not adding data to worksheet

    You've missed code tags, without which your question won't be answered.

  3. #3
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    Thank you for your response, but I don't understand. I am new to VB coding. What code tags am I missing?

  4. #4
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    Ok, I figured out what you meant by code tags. Any help on this issue would be great. Thanks in advance.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: userform not adding data to worksheet

    Your loop through controls to clear does nothing will

    Not sure why you are using the method you have chosed topost. Take a look at the database form here

    http://excel-it.com/vba_examples.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    Looks like the database form link on that page is broken. Do you have another example?

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: userform not adding data to worksheet

    There must be a problem with the server,all the downloads seem to be faulty. I'll look into it, mean while here's another link

    http://www.4shared.com/file/_2fCCa_f...rmAmended.html

  8. #8
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    OK, so I tried this and still nothing. Since I am such a noob to VB scripts, I know I'm missing something important here. The examples you gave were confusing. I really just want to be able to add the data and clear the form for the next entry. Any help would be very appreciated.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    Just tried this one too. No luck. I think I'm digging myself deeper on this.

    Please Login or Register  to view this content.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: userform not adding data to worksheet

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  11. #11
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    Ok, attached is a copy of the file I am working on. The spreadsheet will contain data from a monthly survey. Each section of the survey has between three and five records to be input into the database. I have filled in part of the data base so you can see what I am trying to accomplish. Thank you for your continued help on this.
    Attached Files Attached Files

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,322

    Re: userform not adding data to worksheet

    At a guess, I'd say you renamed the AddRec button after you entered the click event code. As a result the click event code is no longer linked to the button. Change this line:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    and you should be OK.
    Everyone who confuses correlation and causation ends up dead.

  13. #13
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    That worked to get the data onto the worksheet!! Thanks. Now I have a new problem. When I enter the next batch of data, it overwrites the previous one. It does not advance to the next available row. And it pushes all of the data on column off. So the month ends up in the FB1 column.

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,322

    Re: userform not adding data to worksheet

    You are not populating column A, but you are using that to find the next row number, hence you always get the same row number. You either need to change the code to check column B, or you need to start the output in column B.

  15. #15
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: userform not adding data to worksheet

    OK, finally got it working right! A huge thank you to royUK and romperstomper for pointing me in the right direction. I went back to my original script and made some very minor changes. I changed the AddRec button name to
    Please Login or Register  to view this content.
    and changed the range to A1 instead of A2. So simple...

    Please Login or Register  to view this content.
    So the whole code looks like this;
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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