• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Cell coloring using if function

vijehspaul

Member
Hi,

Greetings...

I want to know, can i use function 'if' to color a cell ? if yes How?

I have 3 condition(values) depending on which a cell need to be colored(3 different color). I tried conditional formating. But dont know how to use conditional formating to color a cell in 3 colors.
 
Hi, Vijesh in the conditional formatting use the drop down to "Formula is" and Type your IF formula there. Please let me know if it is not clear for you.
 
Vijesh

Your If formula will be like

=If(A2=1,True, False)

or it can be shortened to

=A1=1

add 3 for each color you need
 
@gobishg: need help. not getting the drop down you mentioned.


@Hui: My formula look like =if(A10="1st value",color1,if(A10="2nd Value",Color2,if(A10="3rd Value",Color3,color4)))

Color4 = worksheet color.


i dont know whether it is the ryt syntax or not....? need your help.
 
I assume this:

=if(A10="1st value",color1,if(A10="2nd Value",Color2,if(A10="3rd Value",Color3,color4)))

is a cell formula, because that isn't how conditional formating works


Conditional Formatting uses the cells value (or another cells value) to determine the format


So in your case you will apply 3 Conditional formats to the same cell/range

CF1: =A1=1st value

set the format to Color 1


CF2: =A1=2nd value

set the format to Color 2


CF3: =A1=3rd value

set the format to Color 3


Set the default cells color to Color 4


Have a read about Conditional Formatting here:


http://chandoo.org/wp/2009/03/13/excel-conditional-formatting-basics/

&

http://chandoo.org/wp/2008/03/13/want-to-be-an-excel-conditional-formatting-rock-star-read-this/
 
Dont know whether I should be asking here.... but this gets into VB territory.....


Conditional interior cell color... How do I find a cellvalue say "V" on Active Sheet and then select only rows (a:f) for the rows that have "V" in them .....


and then


If < the condition you can suggest above > true then


Case Select v, w, x, Y, Z .... please?


VB syntax for above would be greatly appreciated
 
@tom...

I hope u r looking for this :


If Cell.Value = "Value" Then

Cell.Interior.ColorIndex = 3

End If


color index u can find over here : http://www.mvps.org/dmcritchie/excel/colors.htm


@Hui, i will try n update here. Thankzzz
 
yes now what I've tried is for a range R = Range($A3:$F200)


for each Cell in R


and then the cases .....


but I need for formatting to be effected for only $A:$F how do code that bit in?


at the moment


cell.entirerow.interior.color = rgb(192,192,192) for example would highlight the entire row.....


how do I get it to do cell.Range("$A3:$F3").interior.color= rgb(,,) please?
 
Back
Top