Change Cell Color from cell vairable

C

Chillygoose

I need help changing the cell color of excel reports I receive.

when cell A1:A? > cell D1:D? change cell color red

I cant use conditional formating because you have to input cell b
cell, it doesn't do a range.

I need to apply this macro/VBA to excel 2003 worksheets I receive an
apply to the whole document. I think it would be VBA, which I am no
very good with.

Any help is greatly appreciated.

Chill
 
J

JWolf

Select column A by clicking on the A at the top. Do
Format-->Conditional Formatting-->Formula is-->=A1>D1-->Format select
red. No VBA needed. If you really want VBA just turn on the macro
recorder and do the steps above.
 
C

Chillygoose

It doesn't work like that, I already tried. I don't know th
size/amount of cells, it varies. I tried this code =$A:$A>$D:$D unde
the formula portion of conditional formating and it didn't work.

Code is the only way, I tried this on a few cells just to see if i
would work =$A$1:$A25$>$D$1:$D$25 it failed also
 
R

Rob van Gelder

That's not really the way to use Conditional Formatting.

When you're entering your "Formula Is", pretend only the first cell in that
highlight range is selected.

So if you want to change colours for A1:A25:

Highlight A1:A25
Format | Conditional Formatting
Formula Is: =A1>D1


Excel is smart about it. The conditional format for A2 will be =A2>D2. A3
will be =A3>D3. etc...
 
A

Andrew B

hi
This sub will work, however the sub must be able to run automatically when
the cell value changes, so you must store this sub in a special location
such as in the ThisWorkbook object.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Range("B2").Interior.ColorIndex = 0
If Range("B2") > Range("C2") Then Range("B2").Interior.ColorIndex = 3 'red

End Sub

Regards
Andrew Bourke
 
Top