Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value = "" Then Exit Sub
If Not Numbers(TextBox1.Value, 1, 12) Then
MsgBox "Invalid entry"
Cancel = True
End If
If Not Alpha(TextBox1.Value) Then
MsgBox "Alphabets Only"
Cancel = True
End If
If (Not Alpha(TextBox1.Value)) + (Len(TextBox1.Value)<>2) Then
MsgBox "2 Alphabets only"
Cacel = True
End If
End Sub
Function Numbers(ByVal txt As String, myMin As Long, _
myMax As Long) As Boolean
Numbers = ((Val(txt) >= myMin) * (Val(txt) <= myMax))
End Function
Function Alpha(ByVal txt As String) As Boolean
Alpha = (Not txt Like "*[!A-Za-z]*")
End Function