Compare two strings, and find difference? - Page 8

Page 8 of 8 FirstFirst ... 678
Results 71 to 71 of 71

Thread: Compare two strings, and find difference?

  1. #71
    New Member
    Join Date
    Nov 2017
    Location
    Sweden
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare two strings, and find difference?

     
    Quote Originally Posted by Rick Rothstein View Post
    Here is my corrected code... it should work correctly now.
    Code:
    Function Differences(ByVal Str1 As String, ByVal Str2 As String) As String Dim Temp As String, Arr1 As Variant, Arr2 As Variant, Var As Variant Arr1 = Split(Application.Trim(Replace(Str1, ",", " "))) Arr2 = Split(Application.Trim(Replace(Str2, ",", " "))) If UBound(Arr2) > UBound(Arr1) Then Str2 = " " & Application.Trim(Replace(Str2, ",", " ")) & " " For Each Var In Arr1 Str2 = Replace(Str2, " " & Var & " ", " ", , , vbTextCompare) Next Differences = Replace(Application.Trim(Str2), " ", ", ") Else Str1 = " " & Application.Trim(Replace(Str1, ",", " ")) & " " For Each Var In Arr2 Str1 = Replace(Str1, " " & Var & " ", " ", , , vbTextCompare) Next Differences = Replace(Application.Trim(Str1), " ", ", ") End If End Function

    Dear Rick,

    I was trying your cool UDF with my data and wanted to return values in Column C and Column D but somehow it did not work.

    ABCD
    1Main TextRevised CellAdded Text to Main by revised cellRemoved Text from Main by revised cell
    2Washington was born into the provincial gentry of Colonial Virginia to a family of wealthy planters who owned tobacco plantations and slaves, which he inheritedWashington was born into the provincial gentry of Colonial Virginia to a family of wealthy planters who owned tobacco and slaves, which he inherited In his youthIn his youthplantations
    3The amount of military detail handled personally by the President in wartime has varied dramaticallyThe amount of military detail handled personally by the President in wartime has varied dramaticallyNO CHANGENO CHANGE
    4The Department of Defense is headed by the Secretary of Defense, a cabinet-level head who reports directly to the President of the United StatesThe DOD is headed by the Secretary of Defense, a cabinet-level head who reports directly to the President of the United StatesDODDepartment of Defense

    Sheet1








    Last edited by flora1; Dec 5th, 2017 at 11:10 AM.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com