Hi
I have this VBA code but I would like it to not produce an error message if the TextBox is left blank.
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strCode
Dim sOut As String, i As Integer
strCode = Replace(UCase(TextBox5.Value), " ", "")
If Not (strCode Like "[A-Z][A-Z]######[A-D]") Then
MsgBox "Please enter NINO in the correct format", vbCritical
Cancel = True
Else
For i = 1 To 9
Select Case i
Case 3, 5, 7, 9
sOut = sOut & " " & Mid(strCode, i, 1)
Case Else
sOut = sOut & Mid(strCode, i, 1)
End Select
Next i
End If
TextBox5.Value = sOut
End Sub
Thanks
Don
Bookmarks