Thread: Error for loop
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daniel Daniel is offline
external usenet poster
 
Posts: 354
Default Error for loop


Hi
I wrote a VBA to paint a color bar chart if more than 3 days.
Below is my code but it is not working, no painting,
Don't know why, need your help
Thanks
Daniel

----------------------------------------------------------------------------

Sub painting

Dim Rng7 as range
Dim Cnt7 as integer
Cnt7=1

For Each Rng7 In Range(.Cells(2, 6), .Cells(12, 6))
If Rng7.Value = "" Then
Exit For

'If IsEmpty(Rng7) Then
'not working if empty cell

Set Pts = ActiveChart.SeriesCollection(1).Points(Cnt7)

Pts.HasDataLabel = True


If (DateDiff("d", Rng7, Now)) 3 Then

Pts.Fill.Patterned Pattern:=msoPatternDarkUpwardDiagonal

End If
Cnt7 = Cnt7 + 1

End If

Next Rng7
end sub