# Need advice re: macro to compare numbers on 2 different s/s for duplicates

#### Iceberg

##### Board Regular
Hello,

A co-worker has asked me to develop a macro for her. She's pulling two separate reports in SAP and the results get dumped into two separate spreadsheets. The first gives a complete employee listing and the second gives a list of employees who have completed training (both lists contain names and employee numbers).

Since the listings have hundreds of employees, she's looking for a macro that will compare the two. Duplicates will mean that the employee has been trained while single entries mean that the employee hasn't yet undergone training. The output should contain the names and employee numbers, as well as their status (trained/untrained). Since she will be pulling this list several times a month, ideally it would be something that she could run herself.

I've searched similar threads for ideas and am thinking that I may be using VLOOKUP for this. Having said that, I'm a complete VLOOKUP noob and would certainly welcome any advice.

How best do I go about tackling this?

### Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

#### GlennUK

##### Well-known Member
Yes, I'd use VLOOKUP, or maybe MATCH. Using MATCH the formula might look like this:
Code:
``=IF(ISNA(MATCH(employee_cell_ref,employees_trained_range,0)),"Untrained","Trained")``

The MATCH function finds the position of a value in a list. You don't care about the position of the employee in the "completed training" list, but you do care if an employee is not on the list at all. When MATCH can't find a matching entry it returns the #N/A! error, which would mean that the employee is untrained. Using the ISNA function tests to see if a result is the #N/A! error.

#### mikerickson

##### MrExcel MVP
If Sheet2 is Advanced Filtered using Sheet1 names column (no blank rows) as the criteria range, the duplicates will be shown.
The sheet with the criteria range should be the active sheet when AdvancedFilter is pressed.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,681
Messages
5,838,780
Members
430,568
Latest member
bortey

### 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.

### Which adblocker are you using?

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

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