I am making a chart using VBA with a dynamic end. This is cause a new row of data gets added every day. I made the following code:
'
' grafiek Macro
'
'
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Datum"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Cases"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Doden"
Range("$A:$A").Select
ActiveWindow.SmallScroll Down:=-132
Range("$A:$A,$E:$F").Select
Range("E1").Activate
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range( _
"uitslag!$A:$A,uitslag!$E:$F")
ActiveSheet.Shapes("Grafiek 3").IncrementLeft 249
ActiveSheet.Shapes("Grafiek 3").IncrementTop -52.2
ActiveChart.ChartTitle.Select
ActiveChart.ChartTitle.Text = "Coronagegevens"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Coronagegevens"
With Selection.Format.TextFrame2.TextRange.Characters(1, 14).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 14).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
End Sub
It says it can't find the shape "grafiek 3". How can I fix this?
Kind regards