Solved

changing color font in Excel in if  Statement  - Excel 2010

Posted on 2013-11-14
5
496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 36

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

615 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