Your technology certification is waiting. Enroll in Cloud Class ®
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer, j As Integer
If Target.Count = 1 Then
If Len(Target.Value) = 5 Then
For i = 1 To 5
If Asc(Mid(Target.Value, i, 1)) >= 48 And Asc(Mid(Target.Value, i, 1)) <= 57 Then
j = j + 1
If j <> 5 Then
MsgBox "Wrong input"
Application.EnableEvents = False
Application.EnableEvents = True
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.