+ Reply to Thread
Results 1 to 12 of 12

VBA Userform summing the values labels

  1. #1
    Registered User
    Join Date
    04-06-2014
    Location
    Sao Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    19

    VBA Userform summing the values labels

    Hi,


    I would like to know how I can sum all of the Labes for Custo (lblCusto1 etc) and get the answer in the label total (lblTotal1).

    Any help would be greatly appreicated.

    Benedict

    VBALooping.xlsm

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,572

    Re: VBA Userform summing the values labels

    double post http://www.excelforum.com/excel-prog...-userform.html
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    Good evening and welcome to the forum. I'll beg your patience if I've misunderstood your question but when I call up your userform by clicking the "Add Item" button on Sheet "INGREDIENTS" and enter two different ingredients a total pops up in lblTotal1, highlighted in red. If you only enter one ingredient into the form no total shows up in lblTotal1 text box.

    Were you hoping for the total to show up in red in the lblTotal1 cell?

    Again, if I've misunderstood please clarify what you are looking for your code to do. Thanks.

    Matthew

  4. #4
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    I checked out your other thread and it appears your question in that thread was answered so mark that thread as SOLVED by going to the Thread Tools drop down menu at the top of the thread. This way others won't see this as a "double post". As it looks to me, the question you've posted here is slightly different than in the other post, am I correct? Thanks.

    Matthew

  5. #5
    Registered User
    Join Date
    04-06-2014
    Location
    Sao Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA Userform summing the values labels

    Dear Matthew,

    Thanks. I am new to this. I have now marked it as SOLVED.

    Won't happen again.

    Many thanks,

    Benedict

  6. #6
    Registered User
    Join Date
    04-06-2014
    Location
    Sao Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA Userform summing the values labels

    Matthew,

    Do be honest I hadn't got that far yet.
    At the moment what I would like to be able to do is fill in the ComboBox (ComboBox1) and the TextBox (tbQuantUsada1), and have the total show at the bottom of the userform.

    I would like this action to automatically update as I enter more data into the userform.

    Many thanks,

    Benedict

  7. #7
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    I'm new around here too so no worries on not marking your post as SOLVED before. I've made plenty of missteps on the forum so far.

    Now for this,

    Quote Originally Posted by B Eccles-Williams View Post
    At the moment what I would like to be able to do is fill in the ComboBox (ComboBox1) and the TextBox (tbQuantUsada1), and have the total show at the bottom of the userform.

    I would like this action to automatically update as I enter more data into the userform.
    I've done exactly as you described above and after I enter the second ingredient into ComboBox2 and TextBox tbQuantUsada2 the sum of these two entries appears in red in the lblTotal1 TextBox. Try entering two or more ingredients and see what happens on your end.

    Matthew

  8. #8
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    BTW, I noticed that when the cbAddRecord button was clicked on your userform, the code was throwing an error. I added a couple lines to your code and the error issues appears to be addressed:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-06-2014
    Location
    Sao Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA Userform summing the values labels

    Thanks Matthew,

    I guess what I am trying to find out is whether I can sum all of the labels within my userform, or whether I have to input code for every change event, such as:

    HTML Code: 
    And continuing going until lblCusto12

  10. #10
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    I now see what you are talking about. Are the following lines of code what you were hoping to avoid? Are you looking for a way to simplify the code? If so, I believe I've reach the limits of my ability to help. The following lines of code do what you are asking for but it definitely is not the most efficient way of accomplishing your goal.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by moosetales; 05-18-2014 at 11:10 AM.

  11. #11
    Registered User
    Join Date
    04-06-2014
    Location
    Sao Paulo, Brasil
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA Userform summing the values labels

    Matthew,

    Thought that I'd let you know that I managed it!

    I created a new sub, and then just called on that sub for every change event:

    HTML Code: 
    Then:

    HTML Code: 

  12. #12
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: VBA Userform summing the values labels

    Benedict,

    Great. Glad your were able to solve your issue and thanks for sharing the solution.

    Matthew

+ 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. Pivottable: move "∑ values" label between row labels and column labels through VBA
    By Need_help_please in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-14-2018, 05:01 AM
  2. [SOLVED] VBA Looping between Labels Userform
    By B Eccles-Williams in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2014, 08:27 PM
  3. Summing values attached to each of many labels
    By TAGPGA in forum Excel General
    Replies: 2
    Last Post: 12-07-2012, 02:41 PM
  4. VBA Looping with Labels on Userform
    By msommerf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2010, 09:28 AM
  5. [SOLVED] Change values of labels in a userform through another userform
    By Zhennie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-29-2009, 05:34 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