VBA to look for matches and then compare?

goob90

New Member
Joined
Nov 12, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Is it possible to compare two columns for a match and if there is a match compare two other columns?

For example, I want to compare two workbooks with similar data.
  • The FIRST thing I want to check is that there is a match for employee numbers.
  • If there isn't a match, I would want it to be copied and pasted to a new workbook.
  • The SECOND thing I want to check is that if the employee number matches, does the deduction amount?
  • If there isn't a match, I would want it copied and pasted to the same workbook as the first non-matching.
Workbook 1

Recon+ Blueprint.xlsx
ABCD
1NameEmployee ID#Deduction/BenefitDeduction Amount
2Dwight Schrute2669DPHO, DPHO, DPB, DPB$ 81.80
3Jo Bob2308DPHO, DPHO, DPB, DPB$ 56.40
4Ahsoka Tano5134DPLO, DPHO, DPHO, DPFIX, DPB, DPB$ 66.92
Sheet3


Workbook 2
Recon+ Blueprint.xlsx
GHIJ
1Employee NameEmp IDProductTotal Amount Due
2Andy Bernard5687Dental56.4
3Jo Bob2308Dental56.4
4Dwight Schrute2669Dental90
Sheet3



The key here is that I could have non-matches for the first criteria and second criteria on their own sheet so that they can be reconciled. Bonus points if the user can use a macro-assigned button to choose the two workbooks being compared.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,823
Messages
6,181,177
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