Picking out the odd text

MI man

Registered User.
Local time
Today, 07:19
Joined
Nov 23, 2008
Messages
59
Hi,

Can anybody crack this...!!!

I have 2 columns in Excel 2003. The rows of column A contains some text which is the same as the rows in column B, except for few differences.

Eg:
Row 1 of col A: This is a test line
Row 1 of col B: This may be a test line

I have many rows of such kind, and I need to find the odd words out.

Is there any possibility of writing a macro to churn out the odd words out into separate column, say Column C.

Eg:
Row 1 of col A: This is a test line
Row 1 of col B: This may be a test line
row 1 of col C: may be
Here 'may be' is the line that is different from col A

Help...!!!
 
The difference are endless so the anser is probably no, howver if they are always adjacent cells as per your example then

=if(a2=b2," ","different")

would aid a visual check

Brian
 
Something like this will work but it does have limitations such as if there are two occurences of a word in a phrase then it will not pick up the second occurence is missing.

Code:
Sub blah()

Dim arr1 As Variant
Dim arr2 As Variant

Dim blnMatch As Boolean

arr1 = Split(ThisWorkbook.Worksheets("Sheet1").Range("A1").Value, " ")
arr2 = Split(ThisWorkbook.Worksheets("Sheet1").Range("B1").Value, " ")

Dim strMissing As String

For i = LBound(arr2) To UBound(arr2)
    
    blnMatch = False
    
    For k = LBound(arr1) To UBound(arr1)
    
        If arr2(i) = arr1(k) Then blnMatch = True
        
    Next k
    
    
    If blnMatch = False Then
    
        strMissing = strMissing & ", " & arr2(i)
    
    End If
Next i

    
ThisWorkbook.Worksheets("Sheet1").Range("C1").Value = strMissing
     

End Sub
 

Users who are viewing this thread

Back
Top Bottom