
textbox AfterUpdate event
Use the keypress event to examine each key. Reject entries you don't like.
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 Then
KeyAscii = 0
End If
'Don't allow two periods
If InStr(TextBox1.Text, ".") And KeyAscii = 46 Then
KeyAscii = 0
End If
End Sub
The above restricts entries to the numerals 1 to 9 and the period.
Regards,
Tom Ogilvy
MVP Excel
Quote:
> hallo,
> i want excel to check if the value of a textbox that a user has inserted
is
> numeric or not. if the value is not numeric excel should come with a
message
> box like "insert a number!". I tried it with "after update" event but i
did
> not manage to hold the focus on the textbox (and no other command is
> permitted)until a number is inserted.
> does anybody know a solution?
> tia
> lars