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..
LVL 1
Drilon BerishaWeb Developer/AdministratorAsked:
Who is Participating?
 
Santosh GuptaConnect With a Mentor Commented:
Hi,


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.

1.

=mycolor($A$1)=mycolor($B$1)

then select your color

2.
=mycolor($A$1)<>mycolor($B$1)

then select your color

hope it will help you.
0
 
COACHMAN99Commented:
Is the plan to implement this via a conditional formatting formula?
0
 
Drilon BerishaWeb Developer/AdministratorAuthor Commented:
Yes
0
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.

 
COACHMAN99Commented:
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
0
 
MacroShadowCommented:
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.
0
 
Martin LissOlder than dirtCommented:
I've requested that this question be deleted for the following reason:

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

Thanks.
0
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.