Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
' To delete "/" when using Backspace
If KeyCode = 8 And (Len(TextBox1) = 2 Or Len(TextBox1) = 5) Then
TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
Exit Sub
End If
Select Case KeyCode ' To impose numeric characters
Case 96 To 105 ' Allow the following characters: from 0 to 9
Case Else
TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
End Select
If Len(TextBox1) = 11 Then TextBox1 = Left(TextBox1, Len(TextBox1) - 1) ' Number max of characters in the textbox for date format DD/MM/YYYY
' To impose "/" in date format
If Len(TextBox1) = 2 Or Len(TextBox1) = 5 Then TextBox1 = TextBox1 & "/"
End Sub