Can someone please help me, design below code to make it effective to Cell ("A1") only. thank you.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TestCell
Dim RE As Object
Dim REMatches As Object
Set RE = CreateObject("vbscript.regexp")
With RE
.MultiLine = False
.Global = False
.IgnoreCase = True
.Pattern = "[^0-9A-Z,]"
End With
For Each TestCell In Target.Cells
Set REMatches = RE.Execute(TestCell.Value)
If REMatches.Count > 0 Then
MsgBox "Invalid:" & TestCell.Address & "-" & TestCell.Value
TestCell.Value = ""
End If
Next
End Sub
Bookmarks