Highlight the cells that DO Not match a regular expression in Excel.

Sub FlagCellsRegeXnoteq()
'
' Converts each text hyperlink selected into a working hyperlink
'
Dim strSearch As String

Application.ScreenUpdating = False

strSearch = InputBox(Prompt:="Search String.", _
          title:="Search")
          
        If strSearch = vbNullString Then
           Exit Sub
        Else
            Dim re As New RegExp
            re.Pattern = strSearch
            
            
            Dim xCell As Range
            For Each xCell In Selection
                If re.Test(xCell.Text) <> True Then
                    xCell.Select
                    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65115
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
                End If
            Next xCell
    End If

MsgBox "Done"
'
'
End Sub

Comments

Popular posts from this blog

Find countries in a file's text using regular expressions and Perl

Make links active in Excel 2007