jeudi 3 novembre 2016

If Value Doesn't Match Table, Highlight - VBA

I'm looking to loop through column A, and highlight the cell if the value in column C doesn't correspond to the value in a table. For example:

Columns A:C

Table

In the first image, you can see in row 3, the name 'Smith, John' has user 'RKE' which isn't the correct user, when referencing the table. I'm able to set up the following, but I'm stuck there.

Application.ScreenUpdating = False
Dim i As Integer

Sheets("Added(Physical)").Select
Range("A1").Select
lrow = Range(Selection, Selection.End(xlDown)).Count

For i = 2 To lrow

    If Cells(1, i).Value = worksheetapplication.if().Value Then

        i.Interior.Color = 5287936
    End If

Next i

Logically, I would run a vlookup on column A and C, and if there is an error on the vlookup, then the cell color would need to be highlighted.

Anyone have any thoughts on this?

Aucun commentaire:

Enregistrer un commentaire