View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
mangesh_yadav[_19_] mangesh_yadav[_19_] is offline
external usenet poster
 
Posts: 1
Default Conditional format cell ranges with loop?

this should do it......


for i = 13 to RowCount ' starting from 13 as per your example

Range.Cells(i,4).Select ' this is cell D13
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue
Operator:=xlEqual, _
Formula1:="=""x"""
Selection.FormatConditions(1).Font.ColorIndex = xlAutomatic
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF(" & Range.cells(i,4).address & ":"
Range.cells(i,17).address & ",""A"")=2"
Selection.FormatConditions(2).Font.ColorIndex = 46
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF(" & Range.cells(i,4).address & ":"
Range.cells(i,17).address & ",""A"")=3"
Selection.FormatConditions(3).Font.ColorIndex = 3


Next


- Manges

--
Message posted from http://www.ExcelForum.com