Charting error message

A

Ayo

Could someone help me figure out this error message:

" Method 'Axes' of object '_Chart' failed "

I am getting the error on the line: " With .Axes(xlValue, xlSecondary) " in
the following code segment.

Sub createChart()
Dim ChtObj As ChartObject
Dim ChtName As String

Set ChtObj = ActiveSheet.ChartObjects.Add(Left:=375, Top:=7, Width:=575,
Height:=360)

With ChtObj.Chart
.ChartType = xlColumnClustered
.Legend.Position = xlLegendPositionBottom
.SetSourceData Source:=ActiveSheet.Range("$K$26:$L$40")

With .SeriesCollection.NewSeries
.Values = Sheets("SAP# 13195").Range("$M$26:$M$40")
.XValues = Sheets("SAP# 13195").Range("$K$26:$K$40")
.Name = "Cumulative Quantity"
.ChartType = xlLineMarkers

End With

With .Axes(xlValue, xlSecondary)
.MaximumScale = dYmax ' Constant value
.MinimumScale = dYmin ' VBA variable
.MajorUnit = 50
End With

End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top