Find Mismatch Characters:


 Here is a code to highlight the misspelled characters in two Text paragraphs

suppose you have data like this table, and you want to highlight the misspelled characters , you can use given code 

Image

Sub HighlightWrongCharacters()
    Dim bytFirstWord()  As Byte
    Dim bytSecondWord() As Byte
    Dim VarArrData
    Dim lngCOunt        As Long
    Dim lngCOunt2       As Long
    Dim rngRange        As Range
    Dim lngCharIndex    As Long
    Set rngRange = Range(“A1”).CurrentRegion
    VarArrData = rngRange
    For lngCOunt = LBound(VarArrData) To UBound(VarArrData)
        bytFirstWord = VarArrData(lngCOunt, 1)
        bytSecondWord = VarArrData(lngCOunt, 2)
        If UBound(bytFirstWord) = UBound(bytSecondWord) Then
            For lngCOunt2 = LBound(bytFirstWord) To UBound(bytFirstWord)
                If bytSecondWord(lngCOunt2) <> 0 Then lngCharIndex = lngCharIndex + 1
                If bytFirstWord(lngCOunt2) <> bytSecondWord(lngCOunt2) Then
                    rngRange.Cells(lngCOunt, 1).Characters(lngCharIndex, 1).Font.Color = vbRed
                    rngRange.Cells(lngCOunt, 2).Characters(lngCharIndex, 1).Font.Color = vbRed
                End If
            Next
        End If
        lngCharIndex = 0
    Next lngCOunt
End Sub
Sub MakeAutomatic()
    Range(“A1”).CurrentRegion.Font.Color = vbBlack
End Sub
Click here to download .xlsm
Thanks
Rajan.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.