I'm currently using the following function to compare two cells containing strings. It highlights any parts of the string that don't match.
I'd like to be able to make it hightlight parts that do match but dont have the required skill (this function wasa found in a different post onhere)
Any help would be greatly appreciated.Function StringCompare(r1 As Range, r2 As Range) As Boolean Dim oMatches As Object, oMatch As Object Dim r(1 To 2) As Range Dim i As Integer, bDiff As Boolean Set r(1) = r1 Set r(2) = r2 With CreateObject("vbscript.regexp") .Pattern = "\W(\w+)(?=\W)(?=.*\|)(?!.*\|*\1)" .Global = True .IgnoreCase = True For i = 1 To 2 Set oMatches = .Execute("," & r(i).Text & "|" & r(3 - i).Text) For Each oMatch In oMatches With r(i).Characters(Start:=oMatch.FirstIndex + 1, Length:=oMatch.Length - 1).Font .Bold = True .Size = 9 .color = RGB(255, 0, 0) End With Next oMatch If oMatches.Count > 0 Then bDiff = True Next i End With StringCompareHighlight = Not bDiff End Function
Last edited by ianh; 11-19-2010 at 06:46 AM.
Hi ianh
Welcome to the Forum
Please wrap your code in code tags, before the moderators get you...
Forum rules
3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.
Cheers
Sorry, not a good start :-(
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks