Archive of Mr Excel Message Board

Back to Forms in Excel VBA archive index
Back to archive home

changing cell colors with code
Posted by Jeffrey Slavin on August 23, 2001 11:03 AM
i am looking to write code that looks somewhat like the following:
if cellA == cellB then cellB should have the color of blue.
basically i want to be able to change the color of the text or background of a cell if something is true (ie: two cells are equal in this case).
is this possible?
thanks
please email me, JSlavinNU@aol.com

Re: changing cell colors with code
Posted by Mindy on August 23, 2001 11:18 AM
Hi Jeffrey
Yes, it can be done.
Example:
with worksheets(1)
if .range("A1").value = .range("B1") then .range("B1").interior.color = RGB(204,255,255)
end with
204, 255,255 -- light blue
153, 204, 255 -- blue
255, 255, 255 -- white
255,255, 204 -- yellow
153,204,255 -- green
hope this help
Mindy

use Format -> Condition
Posted by Wit on August 27, 2001 1:37 AM
If you want to compare a1 and b1
in Cell B1 use Format ->Condition
Formula is -> =b1=a1
format that you want
After that if you have many rows you want to compare, using format painter.

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.