views:

2572

answers:

4

Hi.

I'm trying to do conditional formatting so that the cell color will change if the value is different from the value in the cell left of it (each column is a month, in each row are the expenses on certain object. I want to monitor easily changes in prices over months.)

I can do it per cell and format-drag it, but I would like a general formula to apply to the whole worksheet.

Thanks!

+5  A: 

When creating your conditional formatting, set the range to which it applies to what you want (the whole sheet), then enter a relative formula (remove the $ signs) as if you were only formatting the upper-left corner.

Excel will properly apply the formatting to the rest of the cells accordingly.

In this example, starting in B1, the left cell would be A1. Just use that--no advanced formula required.


If you're looking for something more advanced, you can play around with column(), row(), and indirect(...).

Michael Haren
A: 

You could use a VBA script that changes the conditional formatting of a selection (you might have to adjust the condition & formatting accordingly):

For Each i In Selection
i.FormatConditions.Delete
i.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:="=" & i.Offset(0, -1).Address
With i.FormatConditions(1).Font
    .Bold = True
End With
Next i
sdfx
+2  A: 
=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1)
Jason Young
Nice, thanks. Michael's answer worked to - but I like explicit formulas...
Using FIVE rarely-used need-to-look-up-the-usage functions instead a simple A1 or RC[-1] relative reference? That's like travelling from Brooklyn to the Bronx with a stop-over in Walla Walla WA!
John Machin
+2  A: 

If you change your cell reference to use R1C1 notation (Tools|Options, General tab), then you can use a simple notation and paste it into any cell.

Now your formula is simply:

=RC[-1]
edoloughlin