Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default charting code hanging up

I have some code that makes a chart and it works great. However, it only
works if the user's computer recognizes a user-defined chart type. In order
to get around it, I am just formating the chart with code.

This is a copy of a segment of the original code:
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="LANL PI"
ActiveChart.SetSourceData Source:=Sheets("Data (altered)").Range( _
"A3:E" & numberrows & ",H3:H" & numberrows), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Performance Index (PI)"""
ActiveChart.SeriesCollection(2).Name = "=""Trend"""
ActiveChart.SeriesCollection(3).Name = "=""Upper Control Limit"""
ActiveChart.SeriesCollection(4).Name = "=""Lower Control Limit"""
ActiveChart.SeriesCollection(5).Name = "='Data (altered)'!R21C6"

With ActiveChart
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
"Performance Index" & Chr(10) & "Larger Numbers are Better"
.Axes(xlCategory).MaximumScale = endchart '38270
.Axes(xlCategory).MinimumScale = 35339
.Axes(xlCategory).MinorUnit = 366
.Axes(xlCategory).MajorUnit = 366
.Axes(xlCategory).Crosses = xlCustom
.Axes(xlCategory).CrossesAt = 0
.Axes(xlCategory).ScaleType = xlLinear
.Axes(xlCategory).DisplayUnit = xlNone
End With


The user-defined code is nothing more than a line chart with a two-color
gradient.

I have changed the code to look like this:

ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Data (altered)").Range( _
"A3:E" & numberrows & ",H3:H" & numberrows), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Performance Index (PI)"""
ActiveChart.SeriesCollection(2).Name = "=""Trend"""
ActiveChart.SeriesCollection(3).Name = "=""Upper Control Limit"""
ActiveChart.SeriesCollection(4).Name = "=""Lower Control Limit"""
ActiveChart.SeriesCollection(5).Name = "='Data (altered)'!R21C6"
With ActiveChart.Axes(xlCategory)

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
"Performance Index" & Chr(10) & "Larger Numbers are Better" 'It
gets hung up here
.MaximumScale = endchart '38270
.MinimumScale = 35339
.MinorUnit = 366
.MajorUnit = 366
.Crosses = xlCustom
.CrossesAt = 0
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
With ActiveChart.PlotArea.Fill
.Visible = True
.ForeColor.SchemeColor = 35
.BackColor.SchemeColor = 22
End With

What would be making it get hung up at that point? That line worked before.
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default charting code hanging up

The line that gets hung-up used to be contained inside a "With ActiveChart"
statement and now is contained inside a "With ActiveChart.Axes(xlCategory)"
statement. In other words, it used to be like saying:
"ActiveChart.Axes(xlValue, xlPrimary)..." which is syntactically correct.
Now it's like saying:
"ActiveChart.Axes(xlCategory).Axes(xlValue, xlPrimary)..." which is not
correct.

Your code could benefit from more efficient use of the "With ActiveChart"
statement. All statements beginning with "ActiveChart" could be contained
within this block statement and therefore you wouldn't need to qualify them.
This applies also to other With/End With statements - i.e. "With
ActiveChart.Axes(xlCategory)" and "With ActiveChart.PlotArea.Fill" could
become "With .Axes(xlCategory)" and "With .PlotArea.Fill" respectively if
they were already contained within a parent "With ActiveChart" statement.

Also, be advised that I get an error trying to change the properties of a
Line Chart, e.g. MaximumScale, MinimumScale etc. It works for me if the chart
is xlScatter. Are you sure you can do this? Maybe I'm just missing something
here. I'll leave it with you.

Regards,
Greg

"Papa Jonah" wrote:

I have some code that makes a chart and it works great. However, it only
works if the user's computer recognizes a user-defined chart type. In order
to get around it, I am just formating the chart with code.

This is a copy of a segment of the original code:
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="LANL PI"
ActiveChart.SetSourceData Source:=Sheets("Data (altered)").Range( _
"A3:E" & numberrows & ",H3:H" & numberrows), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Performance Index (PI)"""
ActiveChart.SeriesCollection(2).Name = "=""Trend"""
ActiveChart.SeriesCollection(3).Name = "=""Upper Control Limit"""
ActiveChart.SeriesCollection(4).Name = "=""Lower Control Limit"""
ActiveChart.SeriesCollection(5).Name = "='Data (altered)'!R21C6"

With ActiveChart
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
"Performance Index" & Chr(10) & "Larger Numbers are Better"
.Axes(xlCategory).MaximumScale = endchart '38270
.Axes(xlCategory).MinimumScale = 35339
.Axes(xlCategory).MinorUnit = 366
.Axes(xlCategory).MajorUnit = 366
.Axes(xlCategory).Crosses = xlCustom
.Axes(xlCategory).CrossesAt = 0
.Axes(xlCategory).ScaleType = xlLinear
.Axes(xlCategory).DisplayUnit = xlNone
End With


The user-defined code is nothing more than a line chart with a two-color
gradient.

I have changed the code to look like this:

ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Data (altered)").Range( _
"A3:E" & numberrows & ",H3:H" & numberrows), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Performance Index (PI)"""
ActiveChart.SeriesCollection(2).Name = "=""Trend"""
ActiveChart.SeriesCollection(3).Name = "=""Upper Control Limit"""
ActiveChart.SeriesCollection(4).Name = "=""Lower Control Limit"""
ActiveChart.SeriesCollection(5).Name = "='Data (altered)'!R21C6"
With ActiveChart.Axes(xlCategory)

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
"Performance Index" & Chr(10) & "Larger Numbers are Better" 'It
gets hung up here
.MaximumScale = endchart '38270
.MinimumScale = 35339
.MinorUnit = 366
.MajorUnit = 366
.Crosses = xlCustom
.CrossesAt = 0
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
With ActiveChart.PlotArea.Fill
.Visible = True
.ForeColor.SchemeColor = 35
.BackColor.SchemeColor = 22
End With

What would be making it get hung up at that point? That line worked before.
TIA

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
selection hanging selection hanging New Users to Excel 2 June 2nd 09 02:41 PM
CHARTING CODE ERROR Jase Excel Discussion (Misc queries) 6 April 11th 08 07:32 PM
Why doesn't Excel 2007 record charting and office art macro code? NOLuckMatt Excel Discussion (Misc queries) 0 August 17th 07 02:38 PM
Excel hanging up Dave Peterson[_3_] Excel Programming 0 September 9th 04 07:10 PM
Automated charting VB code problem Danimal Excel Programming 1 August 28th 04 07:51 AM


All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"