dehachopper
New Member
- Joined
- Aug 27, 2014
- Messages
- 4
I want to make a macro that can check if a cells is contains special character like '%^&' but also alt+enter, here is my macro:
Sub CHECK_Click()
Dim regEx As Object
Dim formulaColorWrong As Long
Dim formulaColorRight As Long
formulaColorRight = RGB(Red:=0, Green:=0, Blue:=0)
formulaColorWrong = RGB(Red:=255, Green:=0, Blue:=0)
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = True
regEx.Pattern = "[!0-9A-Za-z.,@_-]"
Sheets("CheckSheet").Activate
For Each objCell In ActiveSheet.UsedRange.Cells
If regEx.Test(objCell.Value) Then
objCell.Font.Color = formulaColorRight
Else
objCell.Font.Color = formulaColorWrong
End If
Next
End Sub
it works properly but can't catch alt+enter expression.
could someone help me out?
Sub CHECK_Click()
Dim regEx As Object
Dim formulaColorWrong As Long
Dim formulaColorRight As Long
formulaColorRight = RGB(Red:=0, Green:=0, Blue:=0)
formulaColorWrong = RGB(Red:=255, Green:=0, Blue:=0)
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = True
regEx.Pattern = "[!0-9A-Za-z.,@_-]"
Sheets("CheckSheet").Activate
For Each objCell In ActiveSheet.UsedRange.Cells
If regEx.Test(objCell.Value) Then
objCell.Font.Color = formulaColorRight
Else
objCell.Font.Color = formulaColorWrong
End If
Next
End Sub
it works properly but can't catch alt+enter expression.
could someone help me out?