Telpek
Telpek

Reputation: 23

Changing color of cell based on condition

Could you please advise how I can change color of cell D if column B contains names such as B2 = Mary, B3 = Mary etc and column D has percentages such 20%, 30% and if total percentage for all cells in column B containing Mary is not 100% it should color D cells in different color

I tried the below code and it's wrong:

    For w = 3 To 5318

    If .Formula = "=SUMIF($B:$B,$B2,$D:$D)<>1" = True Then

        Range("D" & w).ColorIndex = 3

    End If

    Next

Thanks

Upvotes: 0

Views: 39

Answers (1)

Rik Sportel
Rik Sportel

Reputation: 2679

If it needs to be in a macro, you should reference the interior:

Range("D" & w).Interior.ColorIndex = 3

Upvotes: 0

Related Questions