ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error for loop (https://www.excelbanter.com/excel-programming/403596-error-loop.html)

Daniel

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



All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com