- 05 Mar 2018 às 16:26
#30778
boa tarde amigos,
o que tem de errado nesse código, ele esta dando um erro no bloco with
o que tem de errado nesse código, ele esta dando um erro no bloco with
Código: Selecionar todos
ublic Sub ColorirGrafico()
Dim C As Chart, I As Integer, N As Double
Dim S1 As Series, S2 As Series
Dim objCht As ChartObject
For Each objCht In Planilha1.ChartObjects
If objCht.Chart.Name <> "0" Then
'Set C = Planilha1.ChartObjects("1").Chart
Set S1 = C.SeriesCollection(1)
Set S2 = C.SeriesCollection(2)
'Set S1 = S1.Points(I).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)'
For I = 1 To S1.Points.Count
If S1.Values(I) <= S2.Values(I) And S2.Values(I) > S1.Values(I) Then
S1.Points(I).Format.Fill.ForeColor.RGB = RGB(0, 0, 255)
Else
S1.Points(I).Format.Fill.ForeColor.RGB = RGB(0, 0, 255)
End If
If S2.Values(I) <= S1.Values(I) Then
S2.Points(I).Format.Fill.ForeColor.RGB = RGB(0, 255, 0)
Else
S2.Points(I).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
Next I
End If
Next objCht
End Sub
Private Sub Worksheet_Calculate()
'se houver formulas
ColorirGrafico
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'verificar quando um valor muda
ColorirGrafico
End Sub