Cell Formating

  • Thread starter Thread starter MWilliams
  • Start date Start date
M

MWilliams

I am trying to write a macro that will look at a cell in one workshee
to determine the fill color of a specified range on an othe
worksheet.

example:
if cell A1 in sheet1 = 0 then the fill color for sheet2 cells b2:d
will be red.

Thank
 
Hi,

One way without a macro, is to use Conditional formatting on Sheet2, cells B2:D2 with a formula like
=nCell=0
where nCell is a named reference to Sheet1, A1.

HTH
Anders Silvén
 
If worksheets("Sheet1").range("a1").value = 0 then
with worksheets("sheet2").range("b2:d2").Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
end with

end if

if sheets are in different workbooks add worbooks("name"). befo
worksheets("sheet?")

eg

workbooks("name").worksheets("Sheet1").range("a1
 
I think you mean:

If worksheets("Sheet1").range("a1").value = 0 then
with worksheets("sheet2").range("b2:d2").Interior
.ColorIndex = 3
.Pattern = xlSolid
. PatternColorIndex = xlAutomatic
end with

end if
 
Back
Top