0
votes

I have two data workbooks. One dataset is of refused orders and the other dataset is for current orders. I want to find if i can match orders so that i can utilize the orders that I have in refused file. This way i wont have to make the current order and can simultaneously reduce my stack of orders that have been refused by customers. Here is my Data sheets for refused and current/printed orders. Current/Printed Orders Here is datasheet for the refused orders. Refused Orders

I need to match orders on three things. First the design name needs to match, the product name needs to match and the size needs to match in order to get an "order match".

How can I use excel vba to find matches and create a new excel worksheet in the current order workbook that can show the orders that match between both data sets. The final data output would be order number against order number from both the files.

I am just beginning to learn vba but this is a complex problem that i can not solve. Please help. I wrote a code but it does not run. It says object not defined. Code that i wrote is :

Sub Comparetwosheets()

Dim ws1 As Worksheet, ws2 As Worksheet Dim ws1row As Long, ws2row As Long, w1scol As Integer, ws2col As Integer Dim report As Worksheet Dim row As Long, col As Integer Dim R1 As Range Set R1 = Union(col(5), col(7), col(10))

Set report = Worksheet.Add

'Set numrows = number of rows of data

NumRows = Range("A1", Range("A1").End(xlDown)).Rows.Count ' Select cell a1. Range("A1").Select ' Establish "For" loop to loop "numrows" number of times. For x = 1 To NumRows x = 2 Do While x < NonBlank

   x = x + 1
   
  Do While (ws1.R1 = ws2.R1)
  
  If ws1.rw2 = ws2.rw2 Then
  report.Cells(1, 1).Value = "Match"
  
  Else: x = x + 1
  
  Loop
  
  Loop
 

'Selects cell down 1 row from active cell. ActiveCell.Offset(1, 0).Select

End Sub