Find changes in one sheet and load in another

jcmckeon

New Member
Joined
Nov 4, 2015
Messages
38
Office Version
  1. 365
Platform
  1. Windows
I have a training dashboard with employee names and training they completed. I get new employee lists, I add them to sheet 2. I want to compare sheet 2 (the new employees) with sheet 1 and add a new row with the new employee so I don't add names and have the training columns not match the employee name.

Is there a way to check name on sheet 1, if there then ignore the new entries on sheet 2. If NOT THERE add to sheet 1 by creating new row and adding.

See attached. HOPEFULLY I DID THE MINISHEET CORRECTLY

move employee.xlsx
C
22
Sheet 2


move employee.xlsx
ABCDEFGHI
2Last NameFirst NameDeptComplianceAS9100CertificatesShopOn the JobEpicor
3BalakierMaciejLATHE x x x
4BommerJohnASSEMBLY x x x x x x
5BorowskiAdamLATHE x x x x x x
6BourguillonTomMFG x x x x x x
7BrackettMarieMANGMENT x x x x x x
8BrownNewGuy
9CalzoneJeffreyMILLING x x x x x x
10CalzoneJosephMILLING x x x x x x
11CanepariVincentMILLING x x x x x x
Sheet 1
 

Attachments

  • FINAL LOOK.png
    FINAL LOOK.png
    17.9 KB · Views: 7

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi, One query -

Is the comparison based on First name + Last Name + Dept or only First Name + Last Name ?

Thanks,
Saurabh
 
Upvote 0
Hi, Please check below code.

Code is as per below sheet2 format. If there is any change please share the format of Sheet2.

Training.xlsm
ABC
1Last NameFirst Name
2BalakierPaul
3BommerJohn
4BorowskiAdam
5BrownJim
6
7
8
9
10
11
Sheet2


VBA Code:
Option Explicit

Sub addTeam()
Dim foundcell As Range, rowno As Integer, isAvailable As String
Dim targetrow As Integer, sourcerow As Integer, rowAvailable As Integer

sourcerow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row

For rowno = 2 To sourcerow
    targetrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
    isAvailable = "N"
    For rowAvailable = 2 To targetrow
        If Sheets("Sheet2").Range("A" & rowno) = Sheets("Sheet1").Range("A" & rowno) And Sheets("Sheet2").Range("B" & rowno) = Sheets("Sheet1").Range("B" & rowno) Then
            isAvailable = "Y"
            Exit For
        End If
    Next
    If isAvailable = "N" Then
        Sheets("Sheet1").Range("A" & targetrow + 1) = Sheets("Sheet2").Range("A" & rowno)
        Sheets("Sheet1").Range("B" & targetrow + 1) = Sheets("Sheet2").Range("B" & rowno)
    End If
Next

End Sub
 
Upvote 0
Option Explicit Sub addTeam() Dim foundcell As Range, rowno As Integer, isAvailable As String Dim targetrow As Integer, sourcerow As Integer, rowAvailable As Integer sourcerow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row For rowno = 2 To sourcerow targetrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row isAvailable = "N" For rowAvailable = 2 To targetrow If Sheets("Sheet2").Range("A" & rowno) = Sheets("Sheet1").Range("A" & rowno) And Sheets("Sheet2").Range("B" & rowno) = Sheets("Sheet1").Range("B" & rowno) Then isAvailable = "Y" Exit For End If Next If isAvailable = "N" Then Sheets("Sheet1").Range("A" & targetrow + 1) = Sheets("Sheet2").Range("A" & rowno) Sheets("Sheet1").Range("B" & targetrow + 1) = Sheets("Sheet2").Range("B" & rowno) End If Next End Sub
Hello Saurabhi, thank you for this. I'm having trouble. I opened the Excel workbook, went to developer tab, visual basic, copied/pasted code you provided and got this error. What did I do wrong?
 

Attachments

  • error.png
    error.png
    70.8 KB · Views: 7
Upvote 0
Delete the very first line in that module.
Also in future when copying code, it's best to use the copy icon at the top right of the code window. That will prevent errors like that from happening again.
1644928370962.png
 
Upvote 0
Delete the very first line in that module.
Also in future when copying code, it's best to use the copy icon at the top right of the code window. That will prevent errors like that from happening again.
View attachment 57854
Thank you for this, I'll give it a try. How about a simpler solution. Use conditional format to compare new to main. If new has a name NOT shown on main, highlight that name.
 
Upvote 0
Hi,

Add module in VBA editor as below screenshot and copy the code in module.

1645004982191.png
 

Attachments

  • 1645004879364.png
    1645004879364.png
    188.7 KB · Views: 6
  • 1645004919380.png
    1645004919380.png
    188.7 KB · Views: 7
Upvote 0
Solution

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

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