|
これで如何でしょうか?
アルファベットは大文字・小文字とも許可してあります。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myStr As String
Dim i As Long
If Target.Count <> 1 Then Exit Sub
If Target.Column <> 4 Then Exit Sub
If Target.Value = "" Then Exit Sub
myStr = StrConv(Target.Value, vbNarrow)
For i = 1 To Len(myStr)
If IsNumeric(Mid(myStr, i, 1)) = True Then
ElseIf Mid(myStr, i, 1) = "_" Then
ElseIf Asc(Mid(myStr, i, 1)) >= 65 And Asc(Mid(myStr, i, 1)) <= 90 Then
ElseIf Asc(Mid(myStr, i, 1)) >= 97 And Asc(Mid(myStr, i, 1)) <= 122 Then
Else
MsgBox "X"
Target.Value = ""
Target.Select
Exit Sub
End If
Next i
End Sub
|
|