+ Reply to Thread
Results 1 to 11 of 11

User Form Textboxes not summing values

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    User Form Textboxes not summing values

    Open User form from Sheet 1 and select Name from DropList.
    Opening Balance calculates automatically from the TRANSACTION sheet, and shows the same value in the Closing Balance Textbox, with both boxes formatted as Currency.
    That works perfectly.

    If user then enters a value in either the CREDIT or DEBIT Textbox, the value should format as Currency, and be added to or deducted from Opening Balance to change the Closing Balance.
    Despite multiple attempts with different Codes, this step is not working. It simply overwrites the Closing Balance with the Debit or Credit value as a number, not currency.

    Relevant element of Code as follows:

    Please Login or Register  to view this content.
    Any solutions, suggestions or alternatives welcome as ever

    Ochimus
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: User Form Textboxes not summing values

    Have you tried also (similar to other places in your code):
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

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

    Re: User Form Textboxes not summing values

    Try the attached file. I changed the tboxCREDIT_Change to tboxCREDIT_AfterUpdate and tboxDEBIT_Change to tboxDEBIT_AfterUpdate. The reason for these changes is because "_Change" macros are triggered by the first entry in the textbox. For example, if you wanted to enter 25 in tboxCREDIT, as soon as you enter the number 2, the macro would be triggered and it would not allow you to enter the number 5. The "_AfterUpdate" version will require you to press the RETURN key after the value has been entered. I hope this makes sense.
    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
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: User Form Textboxes not summing values

    Kaper,

    Appreciate the prompt response, but the revised code doesn't work. The values in the Credit and Debit box are still numbers, not currencies, and they are not adding or deducting from the Opening balance.

    Ochimus

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

    Re: User Form Textboxes not summing values

    Have you tried the file I posted in Post #3?

  6. #6
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: User Form Textboxes not summing values

    Mumps,

    Thanks also for your prompt suggestion, which does change the Credit and Debit boxes to currency, but unfortunately it doesn't add or deduct them, because entering a value in either the Debit or Credit box triggers an "Error Code 13" on this line
    Please Login or Register  to view this content.
    It really ought to be straightforward, but I simply cannot see why it isn't working!

    Ochimus

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

    Re: User Form Textboxes not summing values

    I tested the code in the file I attached and it worked properly for me. Are you trying the file I attached or are you trying the code on a different file?

  8. #8
    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,915

    Re: User Form Textboxes not summing values

    If your regional settings are English, CDbl won't convert a US currency formatted value to a double (nor will Val). You'll need to remove the currency symbol using Replace or Mid, then convert to a number, add, and then format again.
    Rory

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

    Re: User Form Textboxes not summing values

    Using @rorya suggestion, see if the attached file works for you.
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: User Form Textboxes not summing values

    Thank everyone, Mump's incorporation of rorya's version cracked it!

    Intriguing point I can't follow is the "Sub SelectCells()" macro in the Module?

    The only issue I can foresee is that entering the Debit value and going straight to the buttons won't change the closing balance, which requires the User to tab away from the Debit textbox. Just have to ensure they understand that!

    Ochimus

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

    Re: User Form Textboxes not summing values

    Glad we could help.
    Would it help if you added a "Label" beside the Debit value and Credit value boxes containing text such as "Press the RETURN key after entering the value."

+ 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. [SOLVED] Excel Office 365 TextBoxes: How Many on a User Form?
    By RmcSsb in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-04-2019, 07:03 PM
  2. [SOLVED] Can't automate sums of variable Textboxes in User Form
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2019, 07:58 AM
  3. Loop to refresh user form TextBoxes
    By lanceloz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2017, 02:36 AM
  4. Given a User Form with 256 textboxes - how can I access a selected one?
    By joebbb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2015, 11:17 AM
  5. Sum 2 textboxes on user form to 3rd when data entered
    By edopts in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-17-2014, 04:04 PM
  6. 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
  7. Formatting alignment in User Form Textboxes
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2011, 01:06 PM

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