Current UDF - Compare two text strings make not case senstive

alex0182828

Board Regular
Joined
Jun 20, 2012
Messages
53
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>
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Watch MrExcel Video

Forum statistics

Threads
1,100,209
Messages
5,473,177
Members
406,850
Latest member
gustavor0

This Week's Hot Topics

Top