The following code is in a userform and what it does is automatically blanks the entry if more than 4 decimal places are input. So the user has to reinput in the textbox. What I'd like to do instead is force the user to input a 0(zero) followed by 4DP ie. if the first character typed isn't a 0 then do not allow any further typing and then it has to be 4 numbers after the . -> is this possible?
[vba]Private Sub Textbox1_Change()
If (Not IsNumeric(TextBox1.Value) And (TextBox1.Value <> "")) Then
TextBox1.Value = Left(TextBox1.Value, Len(TextBox1.Value) - 1)
End If
If (InStr(TextBox1, ".") < (Len(TextBox1) - 4)) And (InStr(TextBox1, ".") > _
0) Then
TextBox1 = ""
End If
End Sub[/vba]
2nd issue is that I have 42 such textboxes that interact with a single sheet - is there any way to apply such code to each textbox without having to have separate change code for every textbox
Any help much appreciated
Jon