View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Charting error message

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