Try :

Sub ConFormatOffset()
    With Range([A1], Cells(Rows.Count, 1).End(xlUp))
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Operator:=xlGreater, _
            Formula1:="=A1>B1"
        .FormatConditions(1).Interior.Color = RGB(255, 0, 0)
    End With
End Sub

Daniel

-----Message d'origine-----
De : excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] De
la part de Natron
Envoyé : jeudi 21 juillet 2011 04:15
À : MS EXCEL AND VBA MACROS
Objet : $$Excel-Macros$$ VBA Conditional Format Offset

I have multiple columns (around 140) of data and need to conditionally
format the data as apposed to looping through.

For instance I have the following data in column A and B.

A B
1 10
2 1
8 4
4 3
5 6

Here is basically what I'm trying to do:
If Column A has a value Greater than Column B then change Column A cell
interior color to red

My attempt in a Macro to perform this task is Below...not quite working

Sub ConFormatOffset()
    With Selection
    Debug.Print ActiveCell
    Debug.Print ActiveCell.Offset(0, 2)
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Operator:=xlGreater,
Formula1:="=A1>Offset(ActiveCell,0,2)"
        .FormatConditions(1).Interior.Color = RGB(255, 0, 0)
    End With
End Sub

--
----------------------------------------------------------------------------
------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip 2. Join our LinkedIN group @
http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and
Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to