Hello,
I am having issue with the last lines of the below.
I am running a VBA to compare 2 workbooks, and copy/paste some info for matching records.
I want to hihlight rows - or at least a cell of nonmatching records.
But it keeps higlighting all records... I do not know the propper line
[vba]If Matchrow > 0 Then
.Cells(i, "BV").Value2 = targetWs.Cells(Matchrow, "E").Value2
ElseIf Matchrow = 0 Then
targetWs.cell.Interior.Color = vbRed[/vba]
Full module is:
[vba]Public Sub GROUPS()
Dim targetWb As Workbook
Dim targetWs As Worksheet
Dim Lastrow As Long
Dim Matchrow As Long
Dim i As Long
Application.ScreenUpdating = False
Set targetWb = Workbooks("T1.xls")
Set targetWs = targetWb.Worksheets(1)
With Workbooks("IT FINAL.xls").Worksheets(1)
Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
For i = 2 To Lastrow
Matchrow = 0
On Error Resume Next
Matchrow = Application.match(.Cells(i, "A").Value2, targetWs.Columns("A"), 0)
On Error GoTo 0
If Matchrow > 0 Then
.Cells(i, "BV").Value2 = targetWs.Cells(Matchrow, "E").Value2
ElseIf Matchrow = 0 Then
targetWs.cell.Interior.Color = vbRed
End If
Next i
End With[/vba]
Can anybody help ?
Thanx