I'm adding a graph to a worksheet using VBA. It's working...but it (usually) seems to be extremely slow as it takes around 20 seconds
It's the third line (Set newChartObj = ...) where VBA usually hangs for around 20 seconds before finally inserting the chart. I then go on to add titles, insert the data series, etc. and this seems to work quickly without any problem.
The spreadsheet itself is quite large (22Mb) as it contains a lot of data but not huge and I have no problems adding graphs manually.
Any suggestions as to why VBA might be taking so long to insert an empty chart?
VBA Code:
Dim newChartObj As ChartObject
Dim newChart As Chart
Set newChartObj = ActiveSheet.ChartObjects.Add(endRange.Left, endRange.Offset(2, 0).Top, 360, 240)
Set newChart = newChartObj.Chart
'Now add all the chart elements
With newChart
'Add titles
'Add data series, etc.
End With
It's the third line (Set newChartObj = ...) where VBA usually hangs for around 20 seconds before finally inserting the chart. I then go on to add titles, insert the data series, etc. and this seems to work quickly without any problem.
The spreadsheet itself is quite large (22Mb) as it contains a lot of data but not huge and I have no problems adding graphs manually.
Any suggestions as to why VBA might be taking so long to insert an empty chart?