Reputation: 37
I have the following which is moving new lines of data to a destination worksheet (wsdest). I tacked on the (Interior.color = RGB(10, 90, 175) portion to ensure that newly added lines are added with a specific color, so they stand out. It was working fine, but I cannot seem to get it to work with the color change.
With wsSource
RowCount = .Cells(.Cells.Rows.Count, "A").End(xlUp).Row
For i = 1 To RowCount
If .Cells(i, "BH").Value = 5 Then
If WorksheetFunction.CountIf(wsDest.Range("A:A"), .Cells(i, "A").Value) = 0 Then
.Cells(i, "A").Copy wsDest.Cells(.Rows.Count, "A").End(xlUp).Offset(1)
wsDest.Cells(.Rows.Count, "A").Interior.Color = RGB(10, 90, 175)
End If
End If
Next i
End With
Upvotes: 0
Views: 44
Reputation: 33692
Try the code below with some modifications I've made:
With wsSource
RowCount = .Cells(.Rows.Count, "A").End(xlUp).Row ' <-- modifed this line
For i = 1 To RowCount
If .Cells(i, "BH").Value = 5 Then
If WorksheetFunction.CountIf(wsDest.Range("A:A"), .Cells(i, "A").Value) = 0 Then
.Cells(i, "A").Copy wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1) ' <-- modifed this line
wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Interior.Color = RGB(10, 90, 175) ' <-- modifed this line
End If
End If
Next i
End With
Upvotes: 1