Find different data between two columns in VBA of Excel Programming

In some cases, you mig­ht want to find diffe­rent data between two colu­mns. In ano­ther word, you may want to cut some fie­ld from one colu­mn if it exi­sts on ano­ther colu­mn. Today I wro­te some lines of code to imple­ment that fun­ction, based on VBA in Excel.

Sub FindDifferent()
Cells(1, 1).Select
height1 = ActiveCell.Row
Cells(1, 2).Select
height2 = ActiveCell.Row
For i = 1 To height1
same = False
For j = 1 To height2
If Cells(i, 1) = Cells(j, 2) Then same = True
If Not same Then
Cells(i, 1).Interior.ColorIndex = 8
'Cells(i, 1).Font.ColorIndex = 8
End If
End Sub

With the fun­ction, we can cut off the same fie­ld and get distin­ctive ones.

You may also like...

Leave a Reply

Your email address will not be published.

eighteen + 19 =