Hello kmeld,
Welcome to the Forum!
On a UserForm, the controls have an Enter and Exit event. This is similar to GetFocus and LostFocus. You tried to add an event that the control did not support. That is why your code didn't work.
Copy this macro to your UserForm. This will format the text box entry once the input is shifted to the next control.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With TextBox1
' If you want to force the user to make entry, delete the next line.
If .Text = "" Then Exit Sub
If IsNumeric(.Text) Then
.Text = Format(.Text, "#0.0 kg")
Else
.Tag = ""
.SelStart = 0
.SelLength = Len(.Text)
MsgBox "Please Enter a Number."
Cancel = True
End If
End With
End Sub
Bookmarks