Automate the Comparison of 2 excel workbooks

derrynek

New Member
Joined
Jul 26, 2019
Messages
1
Hello!! New user and beginner to VBA.


I'm trying to automate the comparison of 2 excel workbooks and have a message box in the masterfile pop out, telling me if theres a math between the total sum of items in "Books-Raw Listing" & "Raw Listing" workbooks.


Here's the tricky part, the transaction codes in both workbooks are different but have same values. Hence, there's a mapping table in the masterfile which helps me to see which matches to which between the 2 wbs. Also, I only want to sum specific values at the time, ie: Only want to sum "Pages" from wb Books-Raw Listing and "RED","SW-OUT" & "DIV" in wb Raw Listing.


I'm aware a simple SUMIF will do the trick, but im trying to automate this function wherby clicking on a command button will have a message box tell me if there's a match or not.


Here's the code i'm currently using but has not worked:
Sub Compare()
wb2 = Application.WorksheetFunction.SumIf(Range("[Books-RawListing.xlsx]Transaction Analysis!A2:A13"), "PAGES", Range("[Books-RawListing.xlsx]Transaction Analysis!H2:H13"))
wb1a = Application.WorksheetFunction.SumIf(Range("[Raw Listing.xlsx]Raw Listing!A2:A13"), "RED", Range("[Raw Listing.xlsx]Raw Listing!F2:F13"))
wb1b = Application.WorksheetFunction.SumIf(Range("[Raw Listing.xlsx]Raw Listing!A2:A13"), "SW-OUT", Range("[Raw Listing.xlsx]Raw Listing!F2:F13"))
wb1c = Application.WorksheetFunction.SumIf(Range("[Raw Listing.xlsx]Raw Listing!A2:A13"), "DIV", Range("[Raw Listing.xlsx]Raw Listing!F2:F13"))

If wb2 = wb1a + wb1b + wb1c Then
MsgBox "Match!"
Else
MsgBox "No Match"
End If
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top