Kmahraz
Member
Hello All,
I have to compare two columns containing string data using VBA, the goal is to return the items not in in list A. The code works, but i would like to see if i can get some help to have a message box that calculate the total of each column and return the values.
SAP DATA : xxx
Items Not in A lists: xxxx
DW PARTS: xxxx
This list is going to be updated each month and I want to be able to compare items instantly.
Best,
Karim
I have to compare two columns containing string data using VBA, the goal is to return the items not in in list A. The code works, but i would like to see if i can get some help to have a message box that calculate the total of each column and return the values.
SAP DATA : xxx
Items Not in A lists: xxxx
DW PARTS: xxxx
This list is going to be updated each month and I want to be able to compare items instantly.
Best,
Karim
Code:
Sub Button1_Click()
Application.ScreenUpdating = False
Dim stNow As Date
stNow = Now
Dim varr As Variant
varr = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Value
Dim arr As Variant
arr = Range("I3:I" & Range("I" & Rows.Count).End(xlUp).Row).Value
Dim x, y, match As Boolean
For Each y In arr
match = False
For Each x In varr
If y = x Then match = True
Next x
If Not match Then
Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1) = y
End If
Next
Range("B1") = "Items not in A Lists"
Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1) = "Items not in I Lists"
'Dim arr As Variant
arr = Range("A3:A" & Range("A" & Rows.Count).End(xlUp).Row).Value
'Dim varr As Variant
varr = Range("I3:I" & Range("I" & Rows.Count).End(xlUp).Row).Value
'Dim x, y, match As Boolean
For Each x In arr
match = False
For Each y In varr
If x = y Then match = True
Next y
If Not match Then
Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1) = x
End If
Next
Debug.Print DateDiff("s", stNow, Now)
Application.ScreenUpdating = True
End Sub