+ Reply to Thread
Results 1 to 14 of 14

Compare Sheets Find Missing Data

Hybrid View

  1. #1
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Compare Sheets Find Missing Data

    Hello and thank you in advance for your help.

    I have an excel workbook that has a master sheet that keeps track of items and there location that constantly changes and another sheet that keeps track of past locations and does not change. Currently when a record is changed in the master sheet the row is manually copied and pasted into the 2nd sheet. I would like a macro that would find items in the master sheet that are not in the 2nd sheet and copy them to the 2nd sheet when records change.

    Example:
    Day1 Workbook appears
    Master Sheet 2
    Equip # Location Equip # Location
    1 shop 1 shop
    2 field 1 2 field 1

    Day2 Workbook changes
    Master Sheet 2
    Equip # Location Equip # Location
    1 field 2 1 shop
    2 field 3 2 field 1
    1 field 2
    2 field 3

    The part I am struggling with is finding rows that appear in the master sheet but not anywhere in sheet 2. There are 6 columns in each row. I just need to be pointed in the right direction. Thank you.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Compare Sheets Find Missing Data

    It will be easy this way - everytime something changes in the master sheet, you clear the contents of sheet 2 and re-update.

    Will this work for you?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Compare Sheets Find Missing Data

    Thank you for the quick reply however that will not work. I am not very good at explaining but the master list is use to be able to find where equipment is at any given time. The second sheet is used to keep track of where equipment has been so the records cannot be deleted.

    I think I could solve it I just don't know how to compare a row in the master sheet with all of the rows in the 2nd sheet regardless of order similar to ISERROR(MATCH(A1,$B:$B,0)) but with vba and all 6 columns.

    Maybe it can't be done.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compare Sheets Find Missing Data

    Hi SuperMan

    I have a sense of what your after but I'd like to see samples of your worksheets (Master and Sheet2). I'd think a Find based on Concatenation would work here.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Compare Sheets Find Missing Data

    Sample.xlsx

    I should have done that right a way sorry. You would not have to compare every column only Job Assignment, Equip #, and Date Out are nessessary. I was originaly thinking of some sort of series of If statements but I am pretty new at this.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compare Sheets Find Missing Data

    Hi ClarkKent88

    Do you not have any code that does Find or Lookup in your current file? Do you not have any Drop Downs that allow you to select, for example Equip#?

    Is your Sample File a true representation of what you currently have? If it is we have a bit of a task ahead of us...not insurmountable...but more difficult and more coding required.

  7. #7
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Compare Sheets Find Missing Data

    Thank you all for your help I found a solution however it does not work in Excel 2003. If anyone knows off the top of their head why that would be great else I think I figure it out. Here is the code.

    HTML Code: 

  8. #8
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Compare Sheets Find Missing Data

    Thank you all for your help I found a solution however it does not work in Excel 2003. If anyone knows off the top of their head why that would be great else I think I figure it out. Here is the code.

    HTML Code: 

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compare Sheets Find Missing Data

    Hi ClarkKent88

    Try this code...I've tested in both 2003 and 2007...let me know of issues
    Public Sub NewEntWhole()
        Dim loM As ListObject, lo2 As ListObject
        Dim TblMData As Variant
        Dim iM As Long
        Dim dDate As Date
        Dim lDate As Long
        Dim rng As Range
        Dim ct As Variant
        Dim shM As Worksheet
        Dim sh2 As Worksheet
        Dim hdM As Integer
        Dim aCell As Range
    
        hdM = 0    'rows above table M
        Set shM = Sheets(1)
        Set sh2 = Sheets(2)
        Set loM = Sheets(1).ListObjects(1)
        Set lo2 = Sheets(2).ListObjects(1)
    
        With loM
            TblMData = .DataBodyRange
        End With
    
        For iM = 2 To UBound(TblMData, 1) + 1
            sh2.Activate
            With lo2
                .Range.AutoFilter Field:=1, Criteria1:=loM.Range(iM, 1).Value
                .Range.AutoFilter Field:=2, Criteria1:=loM.Range(iM, 2).Value
    
                If IsDate(loM.Range(iM, 4)) Then
                    sDate = loM.Range(iM, 4)
                    dDate = DateSerial(Year(sDate), Month(sDate), Day(sDate))
                    lDate = dDate
                    .Range.AutoFilter Field:=4, Criteria1:=">=" & lDate, Operator:=xlAnd, Criteria2:="<" & lDate + 1
                Else
                    .Range.AutoFilter Field:=4, Criteria1:=loM.Range(iM, 4).Value
                End If
            End With
    
            Select Case Val(Application.Version)
    
            Case Is <= 11
                Set aCell = sh2.Range("D1")
                aCell.Select
                With aCell.ListObject.ListColumns(4).Range
                    ct = .Columns(4).SpecialCells(xlCellTypeVisible).Cells.Count - 2
                End With
    
                If ct <= 0 And loM.Range(iM, 1).Value > 0 Then
                    shM.Activate
                    shM.Range(Cells((iM + hdM), 1), Cells((iM + hdM), 7)).Copy
    
                    sh2.Activate
                    NextRow = Range("B65536").End(xlUp).Row
                    Range("A" & NextRow).Select
                    ActiveSheet.Paste
                End If
    
            Case Is >= 12
                Set rng = lo2.AutoFilter.Range
                ct = rng.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1
                If ct = 0 And loM.Range(iM, 1).Value > 0 Then
                    shM.Activate
                    shM.Range(Cells((iM + hdM), 1), Cells((iM + hdM), 7)).Copy
    
                    sh2.Activate
                    NextRow = Range("B65536").End(xlUp).Row + 1
                    Range("A" & NextRow).Select
                    ActiveSheet.Paste
                End If
            End Select
    
            With lo2
                .Range.AutoFilter Field:=1
                .Range.AutoFilter Field:=2
                .Range.AutoFilter Field:=4
            End With
        Next
        shM.Activate
    End Sub

  10. #10
    Registered User
    Join Date
    11-01-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Compare Sheets Find Missing Data

    That works great, Thank You.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Compare Sheets Find Missing Data

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1