Excel Conditions

I need help here with condition on excel

If Cell A2 is the same color as B2 then apply something else on C2..
Drilon BerishaWeb Developer/AdministratorAsked:
Who is Participating?
Santosh GuptaConnect With a Mentor Commented:

use below code as new function.

Function myColor(r As Range) As Integer
    myColor = r.Interior.ColorIndex
End Function

Open in new window

now go to conditional formatting and create two conditions.



then select your color


then select your color

hope it will help you.
Is the plan to implement this via a conditional formatting formula?
Drilon BerishaWeb Developer/AdministratorAuthor Commented:
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I couldn't get the conditional formatting to set the color.
the formula '=A2.interior.color = 255' is accepted but does nothing

macro codewise it is:
If Range("A2").Interior.Color = 255 Then Range("C2").Interior.Color = 150

apparently you cannot get the format directly and should use code. I do it on the sheet selection change event e.g.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Range("A2").Interior.Color = 255 Then Range("C2").Interior.Color = 150
Unfortunately, the Color and ColorIndex properties of a Range don't return the color of a cell that is displayed if Conditional formatting is applied to the cell.  Nor does it allow you to determine whether a conditional format is currently in effect for a cell.

See this article by Chip Pearson for workarounds.
Martin LissOlder than dirtCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Drilon BerishaWeb Developer/AdministratorAuthor Commented:
This Worked Perfect

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.