I have a macro that compares names on two worksheets(LastMonth and ThisMonth) and highlights the new names on ThisMonth. If it finds a name, I would like it to take the value from column E in LastMonth and put it in E for ThisMonth. I think I have a logic error, in that I don't think it accounts for a row that gets skipped. Thanks for looking.
Sub Differences()
Dim cell As Range
Dim irow As Integer
Dim fee As String
irow = 2
With Sheets("ThisMonth")
For Each cell In .Range("a2", .Range("a" & Rows.Count).End(xlUp))
If IsError(Application.Match(cell.Value, Sheets("LastMonth").Range("a:a"), 0)) Then
cell.Offset(, 0).Resize(, 6).Interior.Color = vbYellow
Else
cell.Offset(, 0).Resize(, 6).Interior.ColorIndex = xlNone
'fee = cell.Offset(, 4).Value 'This is reading from the wrong sheet
'fee = Sheets("LastMonth").cell.Offset(, 4).Value 'Error = Object doesn't support this property
fee = Sheets("LastMonth").Range("e" & irow).Value 'Returns wrong answers once a new name occurs
cell.Offset(, 4).Value = fee
irow = irow + 1
End If
Next cell
End With
End Sub
Bookmarks