Private Sub TextBox1_Change()
TextBox1.MaxLength = 8
Select Case Len(TextBox1)
Case 1
If Not IsNumeric(Mid(TextBox1, 1, 1)) Then TextBox1 = ""
Case 2
If Not Mid(TextBox1, 2, 1) Like "[A-Z]" Then TextBox1 = Left(TextBox1, 1)
Case 3, 4, 5, 6, 7, 8
If Not IsNumeric(Mid(TextBox1, Len(TextBox1), 1)) Then TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
End Select
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not TextBox1 Like "#[A-Z]######" Then MsgBox "Saisie invalide.", vbInformation, "Erreur:": Cancel = True
End Sub