• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Message Box, count total of parts in each column

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

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
 

Attachments

  • MPCMaterialMasterFile.xls
    113 KB · Views: 0

Hi !

As per forum rules :

• Any crystal clear explanation ?
• Any attached workbook with a desired result sample ?

For a total, think about Excel functions …
 
Hi:

Is this what you are looking for , If you click on the button it will display the totals as a message box.

Thanks
 

Attachments

  • MPCMaterialMasterFile.xls
    132 KB · Views: 8
Hello Nebu
Sorry for my late response i was out of the country, that's exactly what i was looking for, really appreciate it.
Regards,
Karim
 
Back
Top