So i've been trying to make a sub that makes charts off of some pivot tables in the sheet, the sheet name is "statistics". I was able to make it work a couple of times but now it doesn't work and when i debug it keeps telling me that
is the issue and haven't changed anything? i really don't get it.
Code:
ch2016.Chart.SetSourceData ActiveSheet.Range("A19").CurrentRegion
Code:
Sub Opgave4()
Dim ch2015 As Shape
Dim ch2016 As ChartObject
Dim ch2017 As ChartObject
ActiveSheet.Select
Set ch2015 = ActiveSheet.Shapes.AddChart(Left:=0, Top:=0, Width:=450, Height:=200)
Set ch2016 = ActiveSheet.ChartObjects.Add(Left:=450, Top:=0, Width:=450, Height:=200)
Set ch2017 = ActiveSheet.ChartObjects.Add(Left:=900, Top:=0, Width:=450, Height:=200)
ch2015.Chart.SetSourceData ActiveSheet.Range("A2").CurrentRegion
ch2016.Chart.SetSourceData ActiveSheet.Range("A19").CurrentRegion
ch2017.Chart.SetSourceData ActiveSheet.Range("G1").CurrentRegion
End Sub