Solved

Excel Conditions

Posted on 2014-04-07
8
266 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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modify file details 1 14
Need Help with Mapping ONLY 9 24
Collapse and expand table in Word 2010 2 32
Set WorkSheet  not Working 9 38
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

839 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