Sorry, I suggested the US number format settings.
If the format is other than US try this code:
Private Sub CommandButton1_Click()
Dim ValTB1 As Double
Dim ValTB2 As Double
On Error Resume Next
ValTB1 = CDbl(TextBox1.Value)
ValTB2 = CDbl(TextBox2.Value)
On Error GoTo 0
TextBox3.Value = Format(ValTB1 + ValTB2)
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Text = Format(TextBox1.Text, "#,##0.00")
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox2.Text = Format(TextBox2.Text, "#,##0.00")
End Sub
Private Sub TextBox3_Change()
TextBox3.Text = Format(TextBox3.Text, "$#,##0.00")
End Sub
or another solution with the option of choosing your own currency symbol (in the example $) or national currency symbol (variable strCurCode).
The example is a bit idiotic. I meant to show the possibility of using both symbols.
Option Explicit
Dim strCurCode As String
Private Sub CommandButton1_Click()
Dim ValTB1 As Double
Dim ValTB2 As Double
On Error Resume Next
ValTB1 = CDbl(ClearFormat(TextBox1.Value, "$"))
ValTB2 = CDbl(ClearFormat(TextBox2.Value, "$"))
On Error GoTo 0
'here I used the national currency symbol (strCurCode)
TextBox3.Value = f_CurrencyFormat(ValTB1 + ValTB2, strCurCode)
'TextBox3.Value = f_CurrencyFormat(ValTB1 + ValTB2, "$")
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Text = f_CurrencyFormat(TextBox1.Text, "$")
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox2.Text = f_CurrencyFormat(TextBox2.Text, "$")
End Sub
Private Sub UserForm_Initialize()
strCurCode = Application.International(xlCurrencyCode)
End Sub
Private Function f_CurrencyFormat(ByVal strVal As String, Optional CurrencySign As String) As String
Dim dblVal As Double
strVal = Replace(strVal, CurrencySign, vbNullString)
On Error Resume Next
dblVal = CDbl(strVal)
On Error GoTo 0
f_CurrencyFormat = Format(dblVal, IIf(Len(CurrencySign) = 0, "", CurrencySign & " ") & "#,##0.00")
End Function
Private Function ClearFormat(ByVal strVal As String, Optional CurrencySign As String)
ClearFormat = Replace(strVal, CurrencySign, vbNullString)
End Function
Artik