+ Reply to Thread
Results 1 to 3 of 3

Most Efficient Way in Comparing Two Workbooks and Consolidating Found Differences

Hybrid View

quixter Most Efficient Way in... 08-07-2012, 11:49 AM
quixter Re: Most Efficient Way in... 08-07-2012, 11:52 AM
Xer2 Re: Most Efficient Way in... 08-13-2012, 12:46 PM
  1. #1
    Registered User
    Join Date
    06-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Most Efficient Way in Comparing Two Workbooks and Consolidating Found Differences

    Hi All,

    I was wondering what would be the most efficient way in comparing two workbooks, highlighting the changes, then consolidating the information into a new workbook. What I mean by changes is whether or not there were any changes made to columns B, E, or I from last months deadline list. I am not great at VBA, but I have pieced together some code below.

    Option Explicit
    
    
    Sub TrackChangesQC()
    
    Dim wbkA As Workbook
    Dim wbkB As Workbook
    Dim varSheetA As Variant
    Dim varSheetB As Variant
    Dim strRangeToCheck As String
    Dim iRow As Long
    Dim iCol As Long
    
    Set wbkA = Workbooks.Open(Filename:="Y\PGA_staff\ShafranAY\Production\GA_monthly_deadlines_master_archives\GA_monthly_deadlines_master_0712SRI")
    Set wbkB = Workbooks.Open(Filename:="Y\PGA_staff\ShafranAY\Production\GA_monthly_deadlines_master_archives\GA_monthly_deadlines_master_0612SRIGA_monthly_deadlines_master_0712SRI.xlsGA_monthly_deadlines_master_0612SRI.xls")
    
    
    strRangeToCheck = "A1:AB10000"
    
    Debug.Print Now
    
    varSheetA = Worksheets("Master").Range(strRangeToCheck)
    varSheetB = wbkB.Worksheets("Master").Range(strRangeToCheck)
    
    Debug.Print Now
    
    For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1)
        For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2)
            If varSheetA(iRow, iCol) = varSheetB(iRow, iCol) Then
                'Cells are identical
                'Do nothing
            Else
                'Cells are different
                'Highlight the changes, consolidate the rows and move them into a new workbook
            End If
        Next iCol
    Next iRow
    
    End Sub
    Attached are the sample files I am working with as well if it helps you get a better idea of the situation at hand.
    If anyone would be able to give me some advice and/or help I would greatly appreciate it.

  2. #2
    Registered User
    Join Date
    06-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Most Efficient Way in Comparing Two Workbooks and Consolidating Found Differences

    I apologize, the attachments are now posted.

  3. #3
    Forum Contributor
    Join Date
    07-05-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Most Efficient Way in Comparing Two Workbooks and Consolidating Found Differences

    In terms of Rows and columns, are the worksheets going to be identical, or is this going to need to search through the worksheet to find a matching cell?
    Click on the * icon if this post has been helpful.

+ 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