+ Reply to Thread
Results 1 to 1 of 1

Comparing two workbooks

  1. #1
    Registered User
    Join Date
    05-21-2018
    Location
    USA
    MS-Off Ver
    MS2007
    Posts
    3

    Comparing two workbooks

    Hello,

    Learning VBA on the go here..

    1. Trying to compare two workbooks
    2. Highlight the differences

    The data in both the workbooks looks almost the same. However, I don't know how I can compare A1 and B1 values against the the other workbook. That is my challenge. I don;t know much VBA. I have something like this, but it is not doing what I want it to do.. sigh!


    Sub CompareWorkbooksTwo()


    Dim wbWorkbookOne As Workbook
    Dim wbWorkbookTwo As Workbook

    Application.ScreenUpdating = False

    wb1ws1 = Workbooks("Copy Test_Sheet.xlsm").Worksheets("Functions_SS").Range("A2:B2").Value 'Assumes the first workbook name is 'Book1' and that it's open in the current session.
    wb2ws2 = Workbooks("table_export.xls").Worksheets("ExportWorksheet").Range("A2:B2").Value 'Assumes the second workbook name is 'Book2' and that it's open in the current session.


    For i = LBound(wb1ws1) To UBound(wb1ws1)
    If wb1ws1(i, 1) = wb2ws2(i, 1) Then

    blnSame = True
    Else
    Sheets("Functions").Activate
    ' Order no longer exists so highlight
    Range(i, 1).Select
    With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .Color = 5287936
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    blnSame = False
    Exit For
    End If
    Next i

    If blnSame = True Then
    MsgBox "data is the same"
    Else
    MsgBox "data is different"
    End If
    End Sub

    For EX:
    IDS Users
    FID1 User A
    FID2 UserB
    FID1 UserA
    FID2 UserB
    FID1 User A
    FID2 UserB
    FID1 UserA
    FID2 UserC
    FID1 User A
    FID2 UserB
    FID1 UserA
    FID2 UserB
    Last edited by SL1104; 05-23-2018 at 03:48 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Comparing two workbooks
    By Texbabe in forum Excel General
    Replies: 1
    Last Post: 05-27-2017, 03:50 AM
  2. comparing two workbooks
    By Kenrhoover in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2012, 04:55 PM
  3. [SOLVED] How to make an array of workbooks made up of an array of worksheets?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2012, 08:33 AM
  4. [SOLVED] comparing 2 workbooks
    By komet12 in forum Excel General
    Replies: 1
    Last Post: 04-14-2012, 03:21 PM
  5. Comparing workbooks?
    By guffyuk in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 12-30-2007, 08:03 PM
  6. Comparing Workbooks
    By JS in forum Excel General
    Replies: 2
    Last Post: 10-21-2005, 09:05 AM
  7. comparing workbooks
    By glenn in forum Excel General
    Replies: 1
    Last Post: 08-02-2005, 09:05 AM

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