Text Boxes

Ben S

Board Regular
Joined
Oct 21, 2002
Messages
124
How would i automatically populate a textbox with the sum of 2 other textboxes.

E.g Text box 1 = £6000
Text box 2 = £3000

Text Box 3 would automatically populate with £9000.
 

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.
Andrew, doesn't work for me. Your formula, with = in front, gives #NAME?. Without the = give label in the cell. Where do you put formula, in text box 3 or in a cell in the spreadsheet?
 
Upvote 0
That was VBA code not a worksheet formula.

Code:
Private Sub TextBox1_LostFocus()
    TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value)
End Sub
Private Sub TextBox2_LostFocus()
    TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value)
End Sub
 
Upvote 0
For some reason i have to type a number in the field to enable the textbox to populate with the answer.

Is there a way of automatically populating the textbox with no manual intervention
 
Upvote 0
Yes.

E.g. you may use the "AfterUpdate" event and calculate or other process values in other TextBoxes...
 
Upvote 0
Sorry

I have only started to use Userforms in the last week.

How would i achieve this?
 
Upvote 0
Hi.

In VBE (Visual Basic Editor) double click on TextBox2. Empty code shows. In dropDown (Up-Right) select "AfterUpdate" Event and add code like This:

----------------------------------
Private Sub TextBox2_AfterUpdate()
TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value)
End Sub
----------------------------------

Run forms, and whenever You changes value in TextBox2 - Value in TextBox3 automaticaly will be recalculated.

Same code You may attach for TextBox1 too...
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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