PC Review


Reply
Thread Tools Rate Thread

Charting error message

 
 
Ayo
Guest
Posts: n/a
 
      8th Apr 2009
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
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      9th Apr 2009
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" <(E-Mail Removed)> wrote in message
news:38224F15-37CD-4144-A226-(E-Mail Removed)...
> 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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CHARTING CODE ERROR Jase Microsoft Excel Misc 6 11th Apr 2008 07:32 PM
Allow column selection in excel for charting without error message =?Utf-8?B?TWFyaw==?= Microsoft Excel Crashes 0 10th Aug 2006 07:22 PM
VBA error in charting function. Help! 3PhaseMacroMan Microsoft Excel Programming 1 28th Dec 2005 05:40 PM
Charting error in Excel2003 Julie Microsoft Excel Charting 1 19th Oct 2005 11:42 PM
Custom charting - Stacked charting with a line Randy Lefferts Microsoft Excel Charting 3 3rd Mar 2005 03:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:00 AM.