Hi Dan,
Try this, it should work for the formatting conditions you require from cell
A5 to the bottom of column A.
Public Sub MyConditionalFormatting()
Range(Cells(5, 1), Cells(Rows.Count, 1)).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A5>$B5"
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A5<$B5"
Selection.FormatConditions(2).Interior.ColorIndex = 4
End Sub
As a rookie I would suggest using the Record Macro facility to see roughly
how it happens when you manually enter such code, and build up from there.
Although this won't always give you the exact results you desire, it is a
good starting place for syntax and object names, methods and properties.
The code above should appear from a recorded macro, but I have amended the
code because you might find that a $ appears before the row numbers when you
click a cell to build the formatting formula. If this happens then all the
cells from A5 down would react on the contents of A5 and B5 only. Removing
that $ and running the code means that on subsequent rows the row number is
incremented, so that A6 reacts to the contents of cells A6 and B6.
The second line, with the Delete in it, means that any existing conditional
formats are removed, otherwise you might run into a problem with a max of 3
in Excel 11 and earlier versions. I can't remember the limits of Excel 12 off
the top of my head.
The first line simply selects the cells from A5 to the last row in column A.
The remaining line are self explanatory, they just add the rules and
conditions.
I would just point out that you haven't included A5=B5 in your conditions,
in case you meant to.
Hope this helps,
Sean.