alex0182828
Board Regular
- Joined
- Jun 20, 2012
- Messages
- 88
- Office Version
- 365
- Platform
- MacOS
I use these two UDFS to find the differences between two strings of text, i would be great if they were case insensitive.
If anyone knows how to change these ones or has a better UDF for comparing two text strings ( like with options for choosing different / multiple
seperators etc that would be great ).
Function GetDiffs1(Cell1 As Range, Cell2 As Range) As String Dim Array1, Array2, lLoop As Long Dim strDiff As String, strDiffs As String Dim lCheck As Long Array1 = Split(Replace(Cell1, " ", ""), ",") Array2 = Split(Replace(Cell2, " ", ""), ",") On Error Resume Next With WorksheetFunction For lLoop = 0 To UBound(Array1) strDiff = vbNullString strDiff = .Index(Array2, 1, .Match(Array1(lLoop), Array2, 0)) If strDiff = vbNullString Then lCheck = 0 lCheck = .Match(Array1(lLoop), Array2, 0) If lCheck = 0 Then strDiffs = strDiffs & "," & Array1(lLoop) End If End If Next lLoop End With GetDiffs1 = Trim(Right(strDiffs, Len(strDiffs) - 1)) End Function
Function GetDiffs2(Cell1 As Range, Cell2 As Range) As String Dim Array1, Array2, lLoop As Long Dim strDiff As String, strDiffs As String Dim lCheck As Long Array1 = Split(Replace(Cell1, " ", ""), ",") Array2 = Split(Replace(Cell2, " ", ""), ",") On Error Resume Next With WorksheetFunction For lLoop = 0 To UBound(Array2) strDiff = vbNullString strDiff = .Index(Array1, 1, .Match(Array2(lLoop), Array1, 0)) If strDiff = vbNullString Then lCheck = 0 lCheck = .Match(Array2(lLoop), Array1, 0) If lCheck = 0 Then strDiffs = strDiffs & "," & Array2(lLoop) End If End If Next lLoop End With GetDiffs2 = Trim(Right(strDiffs, Len(strDiffs) - 1)) End Function</pre>
If anyone knows how to change these ones or has a better UDF for comparing two text strings ( like with options for choosing different / multiple
seperators etc that would be great ).
Function GetDiffs1(Cell1 As Range, Cell2 As Range) As String Dim Array1, Array2, lLoop As Long Dim strDiff As String, strDiffs As String Dim lCheck As Long Array1 = Split(Replace(Cell1, " ", ""), ",") Array2 = Split(Replace(Cell2, " ", ""), ",") On Error Resume Next With WorksheetFunction For lLoop = 0 To UBound(Array1) strDiff = vbNullString strDiff = .Index(Array2, 1, .Match(Array1(lLoop), Array2, 0)) If strDiff = vbNullString Then lCheck = 0 lCheck = .Match(Array1(lLoop), Array2, 0) If lCheck = 0 Then strDiffs = strDiffs & "," & Array1(lLoop) End If End If Next lLoop End With GetDiffs1 = Trim(Right(strDiffs, Len(strDiffs) - 1)) End Function
Function GetDiffs2(Cell1 As Range, Cell2 As Range) As String Dim Array1, Array2, lLoop As Long Dim strDiff As String, strDiffs As String Dim lCheck As Long Array1 = Split(Replace(Cell1, " ", ""), ",") Array2 = Split(Replace(Cell2, " ", ""), ",") On Error Resume Next With WorksheetFunction For lLoop = 0 To UBound(Array2) strDiff = vbNullString strDiff = .Index(Array1, 1, .Match(Array2(lLoop), Array1, 0)) If strDiff = vbNullString Then lCheck = 0 lCheck = .Match(Array2(lLoop), Array1, 0) If lCheck = 0 Then strDiffs = strDiffs & "," & Array2(lLoop) End If End If Next lLoop End With GetDiffs2 = Trim(Right(strDiffs, Len(strDiffs) - 1)) End Function</pre>