Compare 2 Workbooks and Highlight Row when there is a data match in one column

mayoung

Active Member
Joined
Mar 26, 2014
Messages
259
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
This is beyond my scope and I need help please. Not even sure where to start.

I have the following two workbooks of Data:

1) Named PartsFile.xml and one sheet named (Parts) This workbook has filtered data, with a header row in the 1st row. Column C is named W/O #. Data is in Columns A:V

2) Named ServiceFile.xml and one sheet named (WIP-MAIN) This workbook has UNFILTERED data, with a header row in the 1st row. Column C is named W/O #. Data is in Columns A:AK

If possible I need to loop through and compare column C (W/O #) in workbooks PartsFile.xml (filtered data) and ServiceFile.xml (unfiltered data) and highlight the ROW when there is a W/O # match in the Servicefile.xml with an Interior.ColorIndex = 33.

Thank You In Advance.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I have been working on the above request and have attached two sample work books you can download from my google drive.
I have also included code I am working with, so far it all works, but it only highlight the work order number when there is a match. I want to add the following if possible.

1) I want to compare both column C (W/O #) & D (SEG #) and only highlight in the ServiceFile workbook if both columns match between both workbooks.

2) I would like to Highlight the entire row if possible, if not just highlight both cells in the row when there is a match.

VBA Code:
Sub Myoung()

Dim wb1 As Workbook, wb2 As Workbook, r As Long, K As String
Set wb1 = Workbooks("ServiceFile.xlsx"): Set wb2 = Workbooks("PartsFile.xlsx")
With CreateObject("Scripting.Dictionary")
r = 2: Do Until wb2.Sheets("PARTS").Range("C" & r) = ""
K = Trim(wb2.Sheets("PARTS").Range("C" & r)): .Item(K) = r
r = r + 1: Loop
r = 2: Do Until wb1.Sheets("WIP-MAIN").Range("C" & r) = ""
K = Trim(wb1.Sheets("WIP-MAIN").Range("C" & r))
            If .Exists(K) Then
wb1.Sheets("WIP-MAIN").Range("C" & r).Interior.ColorIndex = 33
Else
wb1.Sheets("WIP-MAIN").Range("C" & r).Interior.ColorIndex = 0
            End If
r = r + 1: Loop
End With
End Sub


Link To Work Books
 
Upvote 0
I have figured out a way to achieve what I was trying to perform. The service workbook must be opened to run the code. It will check and make sure the parts workbook is open, if it's not it will give you a message to open it. Once both workbooks are open you can run the code.

Service & Parts Workbooks
 
Upvote 0
Solution

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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