Hi,
I am essentially a complete novice at VBA. I have used it in the past but usually only by recording a macro to do what I want, looking at the macro code and attempting to make it automated.
I am working with 2 workbooks of production order data. What I have is a file from last week and a 2nd file from this week. Completed orders will drop out of the 2nd file and I'm not concerned with those. New orders will show up in the 2nd file but there is nothing that identifies them as new orders. What I would like to do is compare each order from the 2nd file to the orders in the 1st file and change the font color of (or highlight) the entire row in the 2nd file if the order is NOT in the 1st file. These would be the new orders I want to view. I have been trying to use the .Find command but am not having any luck. Here is some sample data and the code I am tyring to create. Each order number is unique so there will not be duplicates.
Any help is greatly appreciated.
Thanks,
Bradley
P.S. - Row 1 is blank, Row 2 contains headers and Row 3 begins data
P.P.S. - I am unable to upload a file with the data and macro code, sorry.
Sample data:
Workbook 1 Workbook 2
Order_Number Due_Date P/N Order_Number Due_Date P/N
000500907482 04/18/2012 ITM003690488 0050175100 10/23/2014 SAP000000000540183
000500907483 04/18/2012 ITM003690488 0050175101 11/10/2014 SAP000000000540184
0050194300 11/10/2014 SAP000000000539503 0050284344 10/28/2014 SAP000000001222638
000500903885 04/30/2012 ITM003694834 0050194300 11/10/2014 SAP000000000539503
0050284344 10/28/2014 SAP000000001222638 0050211316 11/10/2014 SAP000000000539479
0050284345 10/28/2014 SAP000000001222639 0050284345 10/28/2014 SAP000000001222639
Sub Compare_to_last_FO_Daily_Dispatch_List()
Dim Order_Number As Object
Dim Order_Number_To_Check As Integer
Dim wkbA As Workbook
Dim wkbB As Workbook
Dim varSheetA As Variant
Dim varSheetB As Variant
Dim New_Order As Range
Dim Check_Order As Range
Set wkbA = Workbooks.Open(Filename:="C:\workbook1.xlsx")
Set varSheetA = wkbA.Sheets("Page2_1").Range("a3:a1500")
Set wkbB = Workbooks.Open(Filename:="C:\workbook2.xlsx")
Set varSheetB = wkbB.Sheets("Page2_1").Range("a3:a1500")
For Each Order_Number In varSheetA
Check_Order = varSheetB.Find(what:="Order_Number", after:="varSheetB(f3)", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If Not Check_Order Is Nothing Then
Else
Order_Number.Parent.Activate
Order_Number.EntireRow.Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End If
Next
End Sub
Bookmarks