Solved

Excel Conditions

Posted on 2014-04-07
8
252 Views
Last Modified: 2014-05-01
I need help here with condition on excel

If Cell A2 is the same color as B2 then apply something else on C2..
0
Comment
Question by:Drilon Berisha
8 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39983634
Is the plan to implement this via a conditional formatting formula?
0
 
LVL 1

Author Comment

by:Drilon Berisha
ID: 39983705
Yes
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39983757
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Expert Comment

by:MacroShadow
ID: 39983850
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
 
LVL 13

Accepted Solution

by:
Santosh Gupta earned 500 total points
ID: 39984391
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40034834
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 1

Author Closing Comment

by:Drilon Berisha
ID: 40034836
This Worked Perfect

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fixing a embedded format 7 30
ADD New Entries 7 16
MS Excel IF AND OR statement 3 31
CUT & PASTE VALUES IN EXCEL USING MACRO -- SPECIFIC CELLS 27 24
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now