Help with Macro - What names are missing or added

thepartydj

Active Member
Joined
Sep 23, 2004
Messages
261
Office Version
  1. 365
Platform
  1. Windows
I have two workbooks. One "Monday" and one "Tuesday"
Each file is the same
Column A = Employee ID
Column B = FIrst Name
Column C = Last Name
Column G = Group

I would like help creating a macro that will compair Monday sheet with Tuesday Sheet. This Macro would need to let me know which items were changed from each list. Some may be deleted, or added or changed. Then copy that entire row to a new sheet on "Tuesday" file.

Thanks in advance for the help!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I found this online.

VBA Code:
Sub CompareVals()


    Application.ScreenUpdating = False
    Dim GL As Range, RngList As Object, rng As Range
    Set RngList = CreateObject("Scripting.Dictionary")
    Dim foundGL As Range
    Dim LastRow2 As Long
    Dim LastRow As Long
    LastRow = Sheets("Sheet2").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    For Each GL In Sheets("Sheet2").Range("A1:A" & LastRow)
        Set foundGL = Sheets("Sheet1").Range("A:A").Find(GL, LookIn:=xlValues, lookat:=xlWhole)
        If Not foundGL Is Nothing Then
            For Each rng In Sheets("Sheet1").Range("A" & foundGL.row & ":G" & foundGL.row)
                If Not RngList.Exists(rng.Value) Then
                    RngList.Add rng.Value, Nothing
                End If
            Next rng
            For Each rng In Sheets("Sheet2").Range("A" & GL.row & ":G" & GL.row)
                If Not RngList.Exists(rng.Value) Then
                    rng.Interior.ColorIndex = 6
                End If
            Next rng
        Else
            GL.EntireRow.Interior.ColorIndex = 3
        End If
    Next GL
    LastRow2 = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    For Each GL In Sheets("Sheet1").Range("A2:A" & LastRow)
        Set foundGL = Sheets("Sheet2").Range("A:A").Find(GL, LookIn:=xlValues, lookat:=xlWhole)
        If foundGL Is Nothing Then
            GL.EntireRow.Interior.ColorIndex = 3
        End If
    Next GL
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,540
Messages
6,179,417
Members
452,912
Latest member
alicemil

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