PossiblyNot
New Member
- Joined
- Jul 11, 2014
- Messages
- 5
Hi all
I've been scratching my head over this problem, it seems a little odd. I have a macro that creates and automatically populates an xy chart. On startup it works, but a few minutes in to using the spreadsheet it suddenly stops working and kicks out a 91 error. sometimes it will all of a sudden start working again.
Could it be possible that there's an issue with selecting the active chart, that a few minutes in I click on a cell, or sheet or object that makes the code kick a fuss?
I can't quite work out what's up :/ a 91 error means I'm not Setting something somewhere, but ActiveChart can't be Set...
Cheers
Rich
I've been scratching my head over this problem, it seems a little odd. I have a macro that creates and automatically populates an xy chart. On startup it works, but a few minutes in to using the spreadsheet it suddenly stops working and kicks out a 91 error. sometimes it will all of a sudden start working again.
Could it be possible that there's an issue with selecting the active chart, that a few minutes in I click on a cell, or sheet or object that makes the code kick a fuss?
Code:
Sub createGraph()
On Error GoTo ErrHandler
'Dim xRow As Long
'xRow = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
ActiveChart.SetElement (msoElementLegendNone) 'Debugger sends me here. When I comment it out...
ActiveChart.SetElement (126) 'This Errors Out
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated) 'Then This
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Age (Ma)" 'Then This
ActiveChart.ChartArea.Select 'You get the Pattern...
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "Biostratigraphy Plot"
ActiveChart.ChartArea.Select
With ActiveChart.Axes(xlValue)
'.HasAxis(xlCategory) = 1
'.HasAxis(xlSeries) = 1
.MinimumScale = 0
.MaximumScale = 80
.ReversePlotOrder = True
.DisplayUnit = xlNone
End With
I can't quite work out what's up :/ a 91 error means I'm not Setting something somewhere, but ActiveChart can't be Set...
Cheers
Rich