ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Charting error message (https://www.excelbanter.com/excel-programming/426638-charting-error-message.html)

Ayo

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

Jon Peltier

Charting error message
 
You must not have a secondary value (Y) axis in the chart. Change
xlSecondary to xlPrimary.

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
Advanced Excel Conference - Training in Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"Ayo" wrote in 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





All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com