How to use regex in general vba sheet. i am getting lot of red lines and not able to find the reason for that.
I have enabled the Regularexpression vbScript also.
Private Const FCheckRgAddress As String = "A1:A100"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As String
Set xChanged = Application.Intersect(Range(FCheckRgAddress), Target)
If xChanged Is Nothing Then Exit Sub
Set xRegExp = CreateObject("VBScript.RegExp")
xRegExp.Global = True
xRegExp.IgnoreCase = True
xRegExp.Pattern = "[^0-9a-z]"
For Each xRg In xChanged
If xRegExp.Test(xRg.Value) Then
xHasErr = True
Application.EnableEvents = False
Application.EnableEvents = True
If a=1 Then
MsgBox "These cells had invalid entries and have been cleared:"
I got it from someother site, most of the lines are red