Here is my corrected code... it should work correctly now.
Code:[TABLE="width: 500"] <tbody>[TR] [TD]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[/TD] [/TR] </tbody>[/TABLE]
Book1 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Main Text | Revised Cell | Added Text to Main by revised cell | Removed Text from Main by revised cell | ||
2 | Washington was born into the provincial gentry of Colonial Virginia to a family of wealthy planters who owned tobacco plantations and slaves, which he inherited | Washington 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 youth | In his youth | plantations | ||
3 | The amount of military detail handled personally by the President in wartime has varied dramatically | The amount of military detail handled personally by the President in wartime has varied dramatically | NO CHANGE | NO CHANGE | ||
4 | The Department of Defense is headed by the Secretary of Defense, a cabinet-level head who reports directly to the President of the United States | The DOD is headed by the Secretary of Defense, a cabinet-level head who reports directly to the President of the United States | DOD | Department of Defense | ||
Sheet1 |
For my code, change the two instances of vbTextCompare to vbBinaryCompare and I think that should work.sorry for bumping an old thread. Does anyone know how to edit the original vba to make this formula to include case sensitive characters?
IE:
A1: My Company, LLC
A2: My Company, Llc
A3: Llc