On this userform I have been working on, basically I have TextBox1 + TextBox2 = Subtotal, Then subtotal + TextBox3 = Grand Total
Which the code looks like this
Then I have
Then each corresponding TextBox_ keypress is this
Then lastly i have the change event for eatch textbox as
This seems like a lot of typing for such a small task but All I am trying to do, and I cannot figure it out for the lkife of me is I want to format TextBox1 like this
textBox1.Value = Format(TextBox1.Value, "$#,##0.00")
Which is fine it formats to that but it quits summing the textboxes once added. I want it to format AND sum the texboxes but I am failing at this simple task and thought I would ask for help beofre I rip my hair out lol... Any thoughts would be greatly appreciated Thank you so kindly
Which the code looks like this
Code:
Private Sub TextBoxSum() Dim Total As Double
Total = 0
If Len(TextBox1.Value) > 0 Then Total = Total + Val(TextBox1Value)
If Len(TextBox2.Value) > 0 Then Total = Total + Val(TextBox2.Value)
Subtotal.Value = Total
End Sub
Then I have
Code:
Private Function NumericOnly(ByVal KeyAscii As MSForms.ReturnInteger) As MSForms.ReturnInteger Dim Key As MSForms.ReturnInteger
Select Case KeyAscii
Case 46, 48 To 57
Set Key = KeyAscii
Case Else
KeyAscii = 0
Set Key = KeyAscii
End Select
Set NumericOnly = Key
End Function
Then each corresponding TextBox_ keypress is this
Code:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)KeyAscii = NumericOnly(KeyAscii)
End Sub
Then lastly i have the change event for eatch textbox as
Code:
Private Sub TextBox1_Change()TextBoxSum
End Sub
This seems like a lot of typing for such a small task but All I am trying to do, and I cannot figure it out for the lkife of me is I want to format TextBox1 like this
textBox1.Value = Format(TextBox1.Value, "$#,##0.00")
Which is fine it formats to that but it quits summing the textboxes once added. I want it to format AND sum the texboxes but I am failing at this simple task and thought I would ask for help beofre I rip my hair out lol... Any thoughts would be greatly appreciated Thank you so kindly