sum value of four textboxes into another text box

R

ron mann

In my userform I have four text boxes. I need to total the value of the first
three text boxes into the forth text box on a change event in any of the
first three text boxes. The values are all currency to two decimal places.

I have done a bit of reading on this but simply can not crack the answer.

Any assistance with the code to do this would be greatly appreciated.
 
E

Eduardo

Hi Ron,
try

If IsNumeric(Me.TxtI1.Value) _
And IsNumeric(Me.Txt2.Value) _
And IsNumeric(Me.Txt3.Value) Then
Me.TxtGrossRevenue.Value = CDbl(Me.Txt1.Value) _
+ CDbl(Me.Txt2.Value) _
+ CDbl(Me.Txt3.Value)

Hope this help
 
R

ron mann

Hi Eduardo,

Based on the code provided by you I have added the code below and the form
works perfectly. Your advice and assistance with this matter is very much
appreciated.

Thanks

Ron.

Private Sub TextBox11_change()
If IsNumeric(TextBox11.Value) Then
Me.TextBox17.Value = CDbl(TextBox11.Value)
End If

End Sub

Private Sub TextBox12_change()
If IsNumeric(TextBox11.Value) _
And IsNumeric(TextBox12.Value) Then
Me.TextBox17.Value = CDbl(TextBox11.Value) + CDbl(TextBox12.Value)
End If

End Sub

Private Sub TextBox13_change()
If IsNumeric(TextBox11.Value) _
And IsNumeric(TextBox12.Value) _
And IsNumeric(TextBox13.Value) Then
Me.TextBox17.Value = CDbl(TextBox11.Value) + CDbl(TextBox12.Value) +
CDbl(TextBox13.Value)
End If

End Sub
Private Sub TextBox14_change()
If IsNumeric(TextBox11.Value) _
And IsNumeric(TextBox12.Value) _
And IsNumeric(TextBox13.Value) _
And IsNumeric(TextBox14.Value) Then
Me.TextBox17.Value = CDbl(TextBox11.Value) + CDbl(TextBox12.Value) +
CDbl(TextBox13.Value) _
+ CDbl(TextBox14.Value)
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top