Sub prova_grafico_with()
If ActiveSheet.ChartObjects(1).Name = "grafico" Then
ActiveSheet.ChartObjects("grafico").Activate
ActiveChart.Parent.Delete
With ActiveSheet.Shapes.AddChart.Chart
.ChartType = xlLineMarkersStacked
.SetSourceData Source:=Range("A21:B" & 21 + [counta(B22:B55)])
.ClearToMatchStyle
.ChartStyle = 43
.ClearToMatchStyle
.SeriesCollecti0n(1).Name = "=""andamento"""
.SeriesCollecti0n(1).ApplyDataLabels
.Parent.Name = "grafico"
End With
Else
With ActiveSheet.Shapes.AddChart.Chart
.ChartType = xlLineMarkersStacked
.SetSourceData Source:=Range("A21:B" & 21 + [counta(B22:B55)])
.ClearToMatchStyle
.ChartStyle = 43
.ClearToMatchStyle
.SeriesCollecti0n(1).Name = "=""andamento"""
.SeriesCollecti0n(1).ApplyDataLabels
.Parent.Name = "grafico"
End With
End If
End Sub |