How do I use the formula for "SUM" in a textbox on a UserFor

34sweetness

Board Regular
Joined
Oct 7, 2002
Messages
136
I have a UserForm that will be used to input inspection data, with a textbox for the Qty Inspected, then several other textboxes to input the number of rejected parts (each textbox for the rejects corresponds to a specific reject code). I then want to have a textbox that will show the sum of the ‘rejects’, meaning I want to add up the total number of rejects. How can I do this, so that the Qty Rejected textbox is ‘automatically’ updated while the data is being input into the ‘reject/code’ textboxes?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You need to add up the values in your text boxes. Say TextBox1 to TextBox3 are your data entry text boxes and TextBox4 is your total text box:

Code:
Private Sub TextBox1_AfterUpdate()
   TextBox4.Value = TextBox1.Value + TextBox2.Value + TextBox3.Value
End Sub

and repeat for TextBox2 and TextBox3.
 

34sweetness

Board Regular
Joined
Oct 7, 2002
Messages
136
On 2002-10-14 12:36, Andrew Poulsom wrote:
You need to add up the values in your text boxes. Say TextBox1 to TextBox3 are your data entry text boxes and TextBox4 is your total text box:

Code:
Private Sub TextBox1_AfterUpdate()
   TextBox4.Value = TextBox1.Value + TextBox2.Value + TextBox3.Value
End Sub

and repeat for TextBox2 and TextBox3.

I did what you stated above, however, this only added the "strings" together. I am entering numbers, and want the total "number" of rejects 'summed up' on the form.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Sorry, I forgot that quirk:

Code:
TextBox4.Value = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value)
 

34sweetness

Board Regular
Joined
Oct 7, 2002
Messages
136
On 2002-10-14 14:15, Andrew Poulsom wrote:
Sorry, I forgot that quirk:

Code:
TextBox4.Value = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value)
Thanks, that works now. Excellent!
 

Forum statistics

Threads
1,143,640
Messages
5,719,984
Members
422,256
Latest member
downeybm

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
Top