Solved

Excel Conditions

Posted on 2014-04-07
8
247 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 26

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 45

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

743 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

11 Experts available now in Live!

Get 1:1 Help Now