MS Excel cell coulor

Microsoft Ms sla excel lic/sa 2yr-1
March 18, 2010 at 19:14:08
Specs: Windows XP
I am trying to change the colour of a cell using the "If Function" i.e. If value of the cell is equal to 20, change colour of cell to green, else colour to be red

See More: MS Excel cell coulor

Report •

March 18, 2010 at 21:25:02
Try posting in the 'Office Software' forum.
(unless the moderator is willing to move it for you)

Report •

March 18, 2010 at 22:53:32
Just in case you don't know where that is here's a link:

Home Page

Report •

March 19, 2010 at 09:42:48
Here is now you can achieve this

If Range("A1").Value = 20 Then
Range("A1").Interior.Color = vbGreen
End If

You can obviously make the code much neater but i odnt kno what you are trying to achieve so have done it pretty works tho.

Report •

Related Solutions

March 22, 2010 at 15:59:08

There is a function known as Conditional formatting that allows you to set things such as cell or font color depending on the value in the cell itself or in another cell.

Before Excel 2007, you could set three cell formatting conditions, for example values less than 20 set cell green, 20 to 89 set cell yellow, 90 or over set cell red. In Excel 2007, a lot more choices exist.

For Excel 2003 do this:
Select cell to 'color'
From the menu select Format, Conditional formatting...
In the drop-down box select 'Cell Value Is'
From the next box select 'equal to' and in the last box enter 20,
finally click format and select the color / font /font color required.
Click OK and OK again.

If you want the color of the cell to change depending on a value in another cell select 'Formula Is' from the first drop-down and enter a formula in the next box, starting with equal.
e.g. =IF(A2=20, TRUE,FALSE)
then select the required format.
If the formula evaluates to TRUE, the selected format is displayed.
Note that TRUE and FALSE are not in quotes - they are Excel's logical values.

You can create quite complex formulas but the formulas must evaluate to either TRUE or FALSE.

Hope this helps.

If you are using Excel 2007, please ask in the Office Software Forum if you need further instructions as CF in Excel 2007 is more complicated.


Report •

Ask Question