Hi all,
I have a set of code to generate a new column of numbers that are present in column B but not in column A. But now I have some data stored in rows, and I have troubles to modify the code to generate a new row to show the difference of two rows of numbers. can someone pls advise. Thx a lot!
here is the original code for columns
I have a set of code to generate a new column of numbers that are present in column B but not in column A. But now I have some data stored in rows, and I have troubles to modify the code to generate a new row to show the difference of two rows of numbers. can someone pls advise. Thx a lot!
here is the original code for columns
Code:
Sub Set_Difference()
Dim colA, colB, ArrList()
Dim i As Integer, j As Integer
Dim theList As New Collection
Dim IsExist As Boolean
Range("F2:F65536").ClearContents
On Error Resume Next
colA = Range("A2:" & "A" & [A65536].End(xlUp).Row)
colB = Range("B2:" & "B" & [B65536].End(xlUp).Row)
For i = 1 To [B65536].End(xlUp).Row - 1
For j = 1 To [A65536].End(xlUp).Row - 1
If colB(i, 1) = colA(j, 1) Then
IsExist = True
Exit For
End If
Next
If IsExist Then
IsExist = False
Else
theList.Add colB(i, 1), CStr(colB(i, 1))
End If
Next
ReDim ArrList(1 To theList.Count, 1 To 1)
For i = 1 To theList.Count
ArrList(i, 1) = theList(i)
Next
Range("F2:" & "F" & theList.Count + 1).Value = ArrList
End Sub