Hi,
I'm trying to compare three worksheets and output data to one of them, however the following code it not quite doing what I've expected. Please see if the following can to modified to assist with my problem.
Sub MatchSheets()
Dim wS As Worksheet, wT As Worksheet, wU As Worksheet
Dim r1 As Range, r2 As Range, r3 As Range
Dim cel1 As Range, cel2 As Range, cel3 As Range
Set wS = ActiveWorkbook.Worksheets("Main")
Set wT = ActiveWorkbook.Worksheets("Summary")
Set wU = ActiveWorkbook.Worksheets("Archived")
With wS
Set r1 = .Range("B2", .Cells(.Rows.Count, .Columns("B:B").Column).End(xlUp))
End With
With wT
Set r2 = .Range("E2", .Cells(.Rows.Count, .Columns("E:E").Column).End(xlUp))
End With
With wU
Set r3 = .Range("F2", .Cells(.Rows.Count, .Columns("F:F").Column).End(xlUp))
End With
On Error Resume Next
For Each cel1 In r1
With Application
Set cel2 = .Index(r2, .Match(cel1.Value, r2, 0)) 'find match in sheet2
If Err = 0 Then
' If cel1.Offset(, 6) <> cel2.Offset(, 6) Then copyRow cel2 'if difference, copy
'' If cel1.Offset(, 4) = cel2.Offset(, 4) Then cel2.Offset(, 4) = cel1.Offset(, 4) 'if difference, copy
If cel2.Offset(, 1) = cel3 & cel2.Offset(, 6) = cel3.Offset(, 7) & cel2.Offset(, 7) = cel3.Offset(, 8) Then 'cel2.Offset(, 4) = cel1.Offset(, 4) 'if difference, copy
cel1.Offset(, 10) = cel2.Offset(, 1).Value & " " & "No Progress"
End If
End If
Err.Clear
End With
Next cel1
Worksheets("Main").Activate
End Sub
Thank you in advance for your assistance.
Bookmarks