Using the Sum Function In a Userform

Burnleyfc

New Member
Joined
Aug 29, 2002
Messages
10
I have a number of dropdown menu's with in a userform and following each selection a number is given (and displayed in a text box) depending on the choice made.

I want a 'totals' text box. How do I add the totals from each box and show the result in the totals box?

Any help appreciated..
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

try:

Private Sub ComboBox1_Change()
TxtTotals = TxtSub1 + TxtSub2 + TxtSub3...
End Sub

TxtTotal is the textbox housing total
TxtSub1,2 etc are the textboxes that are populated by the comboboxs

Do this for each combobox that sends a number to a textbox you wish to include in the total
HTH,
Corticus
 
Upvote 0
Thanks for your help. The 'totals' box is now being populated, but rather than adding the values of the text boxes it is inserting a value separately from each.

I.E: txtsub1 = 1
txtsub2 = 1

txttotal = 11

I have tried putting the statement as a 'sum' and also tried .value for the statement but still come out with the same result.

Any further help would be appreciated.

David
 
Upvote 0
You're right,

That's what I get for not testing my solutions first...

anyway, try this:
Dim CBox1 As Integer
Dim CBox2 As Integer
Dim Cbox3 As Integer


Private Sub ComboBox1_Change()

CBox1 = ComboBox1.Value
TextBox1.Value = CBox1
TextBox4.Value = CBox1 + CBox2 + Cbox3


End Sub

Private Sub ComboBox2_Change()

CBox2 = ComboBox2.Value
TextBox2.Value = CBox2
TextBox4.Value = CBox1 + CBox2 + Cbox3


End Sub

Private Sub ComboBox3_Change()

Cbox3 = ComboBox3.Value
TextBox3 = Cbox3
TextBox4.Value = CBox1 + CBox2 + Cbox3

End Sub

Textbox4 is the totals box. The problem was, the text boxes were holding thir values as text, and not numbers, so + was concatenating instead of summing.

Any troubles, I'll e-mail the file I just did.

HTH,
Corticus

edit: you can format the textboxes for numbers without using variables like I did, but I couldn't get it to work. This way does.
This message was edited by Corticus on 2002-11-07 08:34
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top