Use the Exit Event to format and the change event to validate;
VB:Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) TextBox1 = Format(TextBox1, "$#,##0.00") End Sub Private Sub TextBox1_Change() OnlyNumbers End Sub Private Sub OnlyNumbers() If TypeName(Me.ActiveControl) = "TextBox" Then With Me.ActiveControl If Not IsNumeric(.Value) And .Value <> vbNullString Then MsgBox "Sorry, only numbers allowed" .Value = vbNullString End If End With End If End Sub


Reply With Quote
Bookmarks