Textboxes numbers Sum and formatting

girapas

Board Regular
Joined
Apr 20, 2004
Messages
150
In a userform I have 4 textboxes (tx1, tx2, tx3, tx4) where the user enters numbers.
When a number is entered in any of these textboxes, a corrrespondig textbox
(one of ResultBox1, ResultBox2, ResultBox3, ResultBox4) is populated by a code like this:

Private Sub tx1_Change()
ResultBox1.Value = 2000 * Val(tx1.Text)
ResultBox1.Text = FormatNumber(ResultBox1.Value, 2)
End Sub

So, at each textbox of the ResultBox-column I have numbers like it: 50,000.00
I also have the SUM of the tx1, tx2, tx3, tx4 (in textbox TotalInput) using this code:
TotalInput.Value = Val(tx1.Text) + Val(tx2.Text) + Val(tx3.Text) + Val(tx4.Text)

Things are OK so far. I want the TotalInput number unformatted and I get it.

However, what I need is to have a textbox (TotalResults) with the SUM of the values of
ResultBox1, ResultBox2, ResultBox3, ResultBox4 and with the same format (###,###.00) as above. I've tried the code:

TotalResults.Value = Val(ResultBox1.Text) + Val(ResultBox2.Text) + Val(ResultBox2.Text)_
+ Val(ResultBox4.Text)
FormatNumber(TotalResults.Value, 2) or Format(TotalResults.Value, "#,##0.00") etc.
without succes.
Any help please?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi

Try
Code:
TotalResults.Value = Val(ResultBox1.Text) + Val(ResultBox2.Text) +  Val(ResultBox2.Text)_
                     + Val(ResultBox4.Text)
TotalResults.Value = Format(TotalResults.Value, "#,##0.00")
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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