+ Reply to Thread
Results 1 to 7 of 7

Sum 2 textboxes on user form to 3rd when data entered

  1. #1
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Sum 2 textboxes on user form to 3rd when data entered

    Hello all,
    I am trying to get two text boxes on a userform to populate a third box on the form when the user inputs the data in both of the first two boxes. I am pretty sure i need to use a change event, but I am not sure how or what triggers them. so I have:

    Please Login or Register  to view this content.
    but they don't work when I put data in VSShortPrem and VSLongPrem textboxes. Do I need to call them to the userform module? I am kind of a newbie at this level. Any more information need I would be happy to provide it.

    Thanks in advance!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Sum 2 textboxes on user form to 3rd when data entered

    Hi,

    Can you give a worked example, explaining the result you want to see and upload the workbook so that we can see the request in context.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: Sum 2 textboxes on user form to 3rd when data entered

    were there any error messages?
    did you try running it without the exit sub statements?

    your code is sensible enough for me, a possible reason i see it might return an error though is when if the user inputs a non-numeric character...
    don't worry, there's a lot of people that are far more confused than you
    but if you liked what i suggested. Click for me the "Add Reputation" - that way, we'd be both happy.

  4. #4
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Re: Sum 2 textboxes on user form to 3rd when data entered

    Hi ag,
    There were no error messages and the values are verified as IsNumeric. The VSNetPrem.Value just failed to show up in the cell where it was supposed to on the spreadsheet. I tested the target cell with a different variable in that part of the code.
    If I remove the exit sub statements then I don't need the ifs. It would just be the equation (VSShortPrem - VSLongPrem), which is fine if the user can see the result before they submit the form. If that is an option I would take a look at it.
    Because I will be doing this with 3 and 4 summed boxes in other userforms, I am trying to find a robust method.
    Thanks

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Sum 2 textboxes on user form to 3rd when data entered

    I prefer to use the Val function rather than CDbl, since it doesn't error on alphabetic entries, but I see no reason that the OP code shouldn't put the desired number in VSNetPrem.

    The VSNetPrem.Value just failed to show up in the cell where it was supposed to on the spreadsheet.
    I don't see any code that directs the contents of VSNetPrem to be put on any worksheet.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: Sum 2 textboxes on user form to 3rd when data entered

    the initial post you have above made me think everything only happens in the userform... if you want the end result of the calculation to go into a cell in a worksheet, then the code should have a statement that'll post the code into the worksheet...


    so from the code you have above, if i want the end value to go to cell A1 in sheet1 then i would do it like:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Re: Sum 2 textboxes on user form to 3rd when data entered

    Thanks for the responses. I was away for a few days so I just had a chance to look at this today. I know how to place the value on a spreadsheet. the problem is that I want the user to see the VSNetPrem value in the 3rd textbox before the submit it. Since VSLong and VSShort are being saved on a hidden sheet I can just call the summed value from the hidden sheet to the userform but I was hoping to do it on the form itself.

+ 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. VBA Coding to search a column for data entered in text box on my user form
    By cnkwasher in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2014, 03:11 PM
  2. Copy data from previous row into new row IF user form textboxes are not populated
    By syl127 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2014, 10:35 AM
  3. grouping multiple textboxes on a user form
    By Obfuscated in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2013, 05:31 PM
  4. User Form Data entry trying to check that Data is entered right
    By CityMPLSEmpolyee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2012, 01:23 PM
  5. User form don't write if no data is entered
    By nods in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2010, 12:37 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