View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ahern79 ahern79 is offline
external usenet poster
 
Posts: 11
Default Never Looped before

Bernie,

Will this go through every other row (6, 8, 10, 12...) till it reaches the
end of the range?

"Bernie Deitrick" wrote:

You do not need to loop here, either.

Sub TryNow()
With Range("D6", Cells(Rows.Count, 4).End(xlUp))
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=D6<D5"
With .FormatConditions(1).Font
.Bold = True
.Italic = True
.ColorIndex = 2
End With
.FormatConditions(1).Interior.ColorIndex = 3
End With
End Sub

HTH,
Bernie
MS Excel MVP


"ahern79" wrote in message
...
I have a range of about 6000 rows, 33 columns (starting at column D going to
column AJ).

The issue. Starting at row 5 I want to place a "loop" to conditionally
format row 6 based on the value in row 5. I know that the conditional format
would look like this:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=D6<D5"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = True
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.AutoFill Destination:=Range("D6:AJ6"), Type:=xlFillFormats
Range("D6:AJ6").Select

but I need to repeat this for every row until it reaches the end of the
pivot table. I was copying and pasting fomats but excel didnt like that for
some reason.

I'm hoping an automatic code can be written into this sheet so that it does
it automattically...that would be helpful.

Thank you in advance and please let me know if you need ANY further
information.