View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_6_] Gary Brown[_6_] is offline
external usenet poster
 
Posts: 126
Default EXACT function - but where does it not match?

'/===============================================/
' Function Purpose: Compare where words differ
'/===============================================/
'
Public Function GetNonMatch(Select_1 As Range, _
Compare_2 As Range) As String
Dim i As Integer
Dim sResult As String

On Error GoTo err_Function

Application.Volatile

If Len(Select_1.Value) = 0 Then
sResult = Compare_2.Value
GoTo exit_Function
End If

For i = 1 To Len(Select_1.Value)
If Mid(Select_1.Value, i, 1) < _
Mid(Compare_2.Value, i, 1) Then
sResult = i & " - " & _
Right(Select_1.Value, Len(Select_1.Value) - i + 1)
Exit For
End If
Next i

If Len(Compare_2.Value) Len(Select_1.Value) And _
Select_1.Value = _
Left(Compare_2.Value, Len(Select_1.Value)) Then
sResult = "* - " & Right(Compare_2.Value, _
Len(Compare_2.Value) - Len(Select_1.Value))
End If

exit_Function:
On Error Resume Next
GetNonMatch = sResult
Exit Function

err_Function:
sResult = ""
GoTo exit_Function

End Function
'/===============================================/

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"ana" wrote:

I'm currently using the EXACT function to compare two groups of text.

Is there a macro I can write or function I can use where Excel can tell me,
no it's not an exact match and highlight or format where the text starts to
not match.

So it matches up until it gets to the 255th character, and maybe bolds in
red at the start of non-exact-match.

Please note I'm using Exact b/c the spacing, text, everything within the
cell must exactly match.