Textboxes, chage event and math

Hlatigo

Well-known Member
Joined
Jun 3, 2002
Messages
677
Hello every one! I have 6 textboxes and the first 5 boxes need to be added together and in the sixth textbox is where the answer will be. My problem is I am using afterupdate and it works fine but only for one textbox. Once I move out of the next textbox it does not add up all 5 textboxes. Here is a sample of the code. I hope someone can help, I know it is something dumb I am doing but I cant figure out.




Code:
Private Sub TextBox6_afterupdate()
    If TextBox6.Value <> "" Then
        TextBox11.Value = Format(Val(TextBox6.Value) + Val(TextBox7.Value) + Val(TextBox8.Value) + Val(TextBox9.Value) _
        + Val(TextBox10.Value), "$#,##0.00")
    End If
    
    TextBox6.Value = FormatCurrency(TextBox6.Value)
End Sub

Private Sub TextBox7_afterupdate()
    If TextBox7.Value <> "" Then
        TextBox11.Value = Format(Val(TextBox6.Value) + Val(TextBox7.Value) + Val(TextBox8.Value) + Val(TextBox9.Value) _
        + Val(TextBox10.Value), "$#,##0.00")
    End If

    TextBox7.Value = FormatCurrency(TextBox7.Value)
    
       
End Sub
 
You could strip out the comma and dollar sign using code but is it really worth it?
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,216,071
Messages
6,128,623
Members
449,460
Latest member
jgharbawi

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