Find different data between two columns in VBA of Excel Programming
In some cases, you might want to find different data between two columns. In another word, you may want to cut some field from one column if it exists on another column. Today I wrote some lines of code to implement that function, based on VBA in Excel.
Sub FindDifferent() Cells(1, 1).Select Selection.End(xlDown).Select height1 = ActiveCell.Row Cells(1, 2).Select Selection.End(xlDown).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 Next If Not same Then Cells(i, 1).Interior.ColorIndex = 8 'Cells(i, 1).Font.ColorIndex = 8 End If Next End Sub
With the function, we can cut off the same field and get distinctive ones.