Solved

excel - apply text color in IF statement

Posted on 2014-04-16
26
469 Views
Last Modified: 2014-04-23
Hello Experts
I am commuting some values in Excel using quite a few IF statements, I want to apply different colors to the text to highlight the affected columns.
Please can someone advise how can I set text color using Formula in Excel?
Thanks
0
Comment
Question by:johnhill2312
  • 12
  • 10
  • 4
26 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004239
Hi,

Could you sample of what you want to do?

Regards
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 40004240
You can't actually affect the font colour using the formula within the cell but you can use Conditional Formatting (CF) to affect the font colour of a cell. The conditions in the CF can be formula driven.

Thanks
Rob H
0
 

Author Comment

by:johnhill2312
ID: 40004263
Hello both, thanks for your input

I have this formula in place, if the condition satisfies then I want to set the AVERAGE in RED.


IF(inventory!RC=0,AVERAGE(inventory!RC2:RC13),0)

Thanks
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 40004295
I assume this is the formula in the cell.

For one, it does not make sense. The "Inventory!RC=0" is missing a row number. What are you tring to achieve with the formula.

What condition do you need to be satisfied for font to go Red? Equal to zero or not equal to zero?

Thanks
Rob H
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004328
Hi,

if you want to change in red the text appearing where this formula iss
IF(inventory!RC=0,AVERAGE(inventory!RC2:RC13),0)

Open in new window


Use This formula in the Conditional Formatting ( In Start Conditional Formatting / New Rule / Formula ...)

IF(inventory!RC=0,1,0)

Open in new window

and use the format you need

like in the example

Regards
EE20140416.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40004334
Hi,
Please check the report sheet, I am checking the values from the previous 2 sheets and writing down the Average if the Sheet2 cell=0
I have marked one of the value to RED manually, I want to apply the RED font using the formula.
thanks
stock-zero-coz-oos-or-new-exampl.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40004356
Hi Rob
I want to check if RC not equal to zero   OR if its null, then I want the font to go RED.
Thanks
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004361
HI,

Is that what you are looking for?
EDITED

Version2
Regards
stock-zero-coz-oos-or-new-V2.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40004374
Hi Rgonzo1971
Thanks for the attachment, am sorry but cannot see your changes? Please can you let me know what did you change or please upload the file again.
Many thanks
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 40004378
Apologies about the RC comment earlier, hadn't realised you were using R1C1 style references.

I will take a look at the Conditional Formatting.
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004390
Before seeing your comment  if RC is equal to zero

Now on the report sheet the value is equal to zero and the one where there is zero in the inventory sheet are in red
0
 

Author Comment

by:johnhill2312
ID: 40004394
still dont see the changes  Rgonzo1971 - please see the screenshot...

am i missing something?
screen.png
0
 
LVL 31

Expert Comment

by:Rob Henson
ID: 40004416
I have downloaded Rgonzo's file and I see the Conditional Formatting applied.

Slight change suggested for formula in CF, it doesn't need to be enclosed in an IF statement; it can just be:

=OR(RC=0,inventory!RC=0)

CF looks for a True or False result, 1 = True and 0 = False in your IF statement but as the OR statement gives a True or False anyway, the IF isn't required.

Do you also need to make Red if Sales History is zero?

Thanks
Rob H
0
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.

 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004426
I forgot Excel does not translate formulas in the conditional formatting ( I have another Language version)

pls try this

Regards
stock-zero-coz-oos-or-new-V3.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40004577
Hi Rob

>>Do you also need to make Red if Sales History is zero?

Yes please

not sure why I am unable to see the changes you are sending Rgonzo1971
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004581
Now the CF with no function

=(RC=0)+(inventory!RC=0)

Regards
stock-zero-coz-oos-or-new-V4.xlsx
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40004593
New formula

Taking account if Sales History is zero

=(B2=0)+(inventory!B2=0)+('prod-sales-history'!B2=0)

Regards
stock-zero-coz-oos-or-new-V5.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40006171
Hi Rgonzo1971
Thanks again for your reply
Please can you write down your steps ... I mean how can I reproduce the results you are explaining.

I cannot see anything under Condtional Formatting ->Manage rules ??
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40006193
Hi,

At best you select the Cell B2 in the report sheet

Then goto Home / Styles / Conditional Formatting / Manage Rules / Add (in this case Edit) Rule / Use a Formula...

Place the formula in the Textbox Click Format to see what is the applied format to the condition

Regards
0
 

Author Comment

by:johnhill2312
ID: 40006218
Hi Rgonzo
Thanks again, when I followed the steps mentioned above, I am getting an error, attached.
Please advice
screen.png
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40006299
Hi,

I forgot you have XL2007 it means you cannot use in a formula a different worksheet but

there is a workaround with Named Ranges

I created ProdRange and InventoryRange by going to Formulas Defined Names Define Name

Refers to ='prod-sales-history'!$B$2:$M$5 & =inventory!$B$2:$M$5  respectively

then used

this formula in the Conditional Formatting

=(B2=0)+(OFFSET(ProdRange,ROW(B2)-2,COLUMN(B2)-2,1,1)=0)+(OFFSET(InventoryRange,ROW(B2)-2,COLUMN(B2)-2,1,1)=0)

see above to insert it

Regards
stock-zero-coz-oos-or-new-V6.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40007043
Thank you again for your help, really appreciate it.
I am now trying to figure what is going wrong in the attached, as adviced  I have created Range names and used it in the formula, however its applying RED font to even CELLS which does not qualify the statement.

Please can you advice?

Many thanks
stock-zero-coz-oos-or-new-V5-1.xlsx
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40007105
Hi,

In your file the formula you have


=(B2=0)+(OFFSET(ProdRange,ROW(B2)-2,COLUMN(B2)-2,1,1)=0)+(OFFSET(InventoryRange,ROW(B2)-2,COLUMN(B2)-2,1,1)=0)

but instead of B2 you have B3

that's the problem

select all the cells and delete the conditional formatting by deleting the rule

then retry by selecting the cell B2

end enter the formula

and then select the range it will be applied to

Regards
Kopie-von-stock-zero-coz-oos-or-.xlsx
0
 

Author Comment

by:johnhill2312
ID: 40007163
Oh great!! I got it finally. I really hope when I take this across my real and very complicated sheet - it works!!!

I am sure it will as you have explained it really very well!!

Many thanks again for your help and time!!

Really appreciate it.

Have a good weekend!!
0
 

Author Closing Comment

by:johnhill2312
ID: 40007164
Many thanks...
0
 

Author Comment

by:johnhill2312
ID: 40018049
hi Rgonzo1971

please can you visit: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28418455.html

I am having a small problem in the formula again...   please can you check?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
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;…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

17 Experts available now in Live!

Get 1:1 Help Now