+ Reply to Thread
Results 1 to 6 of 6

Summing TextBox Values

  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Summing TextBox Values

    I was using the code below to sum the values of TextBoxes (7 in total).
    I am now programmatically generating the TextBoxes as required, the naming convention remaining txtPrice, txtPrice1, txtPrice2 etc.
    I do have a count of TextBoxes generated in the userform = txtLines.Value.
    Is there some kind of loop that would sum the variable number of TextBox values?
    Thanks Sandy
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Summing TextBox Values

    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Summing TextBox Values

    Hello gsandy,

    Here is another way...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Summing TextBox Values

    Apologies guys for the delay in getting back to you. I got side tracked into another area of the same project. Thanks for the code, I will try both.
    Cheers Sandy

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Summing TextBox Values

    Quote Originally Posted by Leith Ross View Post
    Please Login or Register  to view this content.
    If the user's decimal point is a dot, the CDbl function call can be changed to a Val function call thus allowing you to remove the two On Error statements which, in turn, would allow your code to be simplified like so...
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Summing TextBox Values

    Thanks Rick, both yours and Leith's code worked a charm. Cheers Sandy

+ 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. Userform textbox summing with a twist
    By jet2004uk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2018, 07:22 AM
  2. Textbox values to match value in textbox 1 on a userform
    By Shellybelly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-03-2015, 05:29 PM
  3. [SOLVED] Summing values in one column based on their adjacent values
    By undoubtedlymegz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-07-2013, 04:57 PM
  4. Userform to search textbox value to place other textbox values in worksheet
    By mattyh555 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:38 AM
  5. Replies: 5
    Last Post: 11-18-2010, 05:37 PM
  6. Userform: Pass textbox values to another textbox on button press
    By adjustermn in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2010, 11:19 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