• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Highlight Value if not in array

Nitesh Khot

Member
I want to highlight cell value if not present in array..

ie. if in array("IN","US","SG")

If in Range(A2) to last row if cell value not in array then highlight cell as red backcolor.

Thanks in advance,
Nikh
 
Hi @Nitesh Khot

I believe this will do:
Code:
Sub test()

    Dim array_test(2)
    Dim c As Range
   
    array_test(0) = "IN"
    array_test(1) = "US"
    array_test(2) = "SG"
   
    For Each c In Range("A2:A" & Range("A2").End(xlDown).Row).Cells
        If IsError(Application.Match(c.Value, array_test, False)) Then
            c.Interior.ColorIndex = 3
        End If
    Next c

End Sub

Hope this helps :)

Regards
 
Back
Top