Option Explicit
Public CCN As Range
Sub x()
Dim CCNEmpty As Boolean, _
CCN_OK As Boolean
Select Case Range("M14").Value
Case Is = "Blank"
MsgBox "Please select the business unit.", vbOKOnly
Range("F14").Activate
Exit Sub
Case Is = 1
CCN_OK = Val_CCN("9###023###")
If Not CCN_OK Then
MsgBox "Error! The format must be 9xxx023xxx.", vbOKOnly
CCN.ClearContents
CCN.Activate
End If
Case Is = 2
CCN_OK = Val_CCN("9###002###")
If Not CCN_OK Then
MsgBox "Error! The format must be 9xxx002xxx.", vbOKOnly
CCN.ClearContents
CCN.Activate
End If
Case Is = 3
CCN_OK = Val_CCN("9###401###")
If Not CCN_OK Then
MsgBox "Error! The format must be 9xxx401xxx.", vbOKOnly
CCN.ClearContents
CCN.Activate
End If
End Select
End Sub
Function Val_CCN(ByVal Val_String As String) As Boolean
For Each CCN In Range("G25:G34")
If Not CCN Like Val_String Then
Val_CCN = False
Exit For
End If
End Function
** No sample file
= no check
tsk, tsk, tsk
Bookmarks