• 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.

Check value available or not in 3 cell

Nitesh Khot

Member
Hi,

How to compare 3 cells value available or not..

ie. A2 B2 C2

I want to check any if value is available or not in any one of the cell...if 3 cells are empty then highlight as red.

Thanks,
Nikh
 
Hi,

In my opinion you don't need VBA for this... just select the cells and apply conditional formatting to highlight if cell =0

If you must use VBA then:
Code:
Sub test()

    Dim c As Range
   
    For Each c In Range("A2:C2").Cells
        If c.Value = 0 Then
            c.Interior.ColorIndex = 3
        End If
    Next c

End Sub

Hope it helps

Regards
 
I just realized you probably want to highlight all 3 cells if all 3 are blank... if so:
With conditional formatting, use formula like:

=and($A$2="";$B$2="";$C$2="") and format to red background

for VBA:
Code:
Sub test()

    If WorksheetFunction.CountA(Range("A2:C2")) = 0 Then
        Range("A2:C2").Interior.ColorIndex = 3
    End If

End Sub

Regards
 
Last edited:
Back
Top