Cell Formating

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
 
A

Anders S

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
 
M

mudraker

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top