Solved

changing color font in Excel in if  Statement  - Excel 2010

Posted on 2013-11-14
5
484 Views
Last Modified: 2013-11-14
Experts,

Is there a way to change the color of the font in an if statement relative to if the calculation is negative or positive.

I would like to put this statement in columnd d14

If (d14-AVERAGE($d14:$G14) < 0 then  ...........

I would like to change the font  in D14 to red if negative and green if positive.
0
Comment
Question by:morinia
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 39648272
I think you have yourself a circular reference.
In any case, after you solve that, use Conditional Formatting (new rule, based on formula, one for D14>-1, and one for D14 <0)
0
 
LVL 12

Assisted Solution

by:Harry Lee
Harry Lee earned 250 total points
ID: 39648569
morinia,

there is no circular reference in the formula in your question. Kimputer is absolutely wrong on that.

You would have to use Conditional Format in this situation. On D14, apply Conditional Format using New Rule. Use use a Formula to Determine which cells to format.

In the formula field, type in
=D14-AVERAGE($D14:$G14)<0

Or even more straight forward,

=D14<Average($D14:$G14)

Then, click Format button and change the font color to Red.

Take a look at the sample file.
Book1.xlsx
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 250 total points
ID: 39648723
There is also a specific option to do this in conditional formatting without using a formula.....

Select the range D14:G14

Conditional formatting > New rule > Format only values that are above or below average > Select "Above" from dropdown and select required format

Repeat the process for "Below"

regards, barry
0
 
LVL 12

Expert Comment

by:Harry Lee
ID: 39649596
Barry,

You method works somewhat. With a formula situation, the only cell that's affected is D14. With you method, the whole range D14:G14 is affected.

As stated in the question, only D14 should be affected but not the average range.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39649635
Hello Harry,

That's true

I assumed that morinia would want to format the whole range so that each value will be coloured according to whether it's above or below average.....

...perhaps I'm wrong but morinia seemed happy with that solution :)

regards, barry
0

Featured Post

What Security Threats Are You Missing?

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.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

758 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

13 Experts available now in Live!

Get 1:1 Help Now