J
Jonnyboy117
I have a weird problem when trying to plot an XYScatterSmooth series
from imported tabulated data. The chart is generated properly, but it
seems to be drawing itself multiple times, and after several seconds I
get a runtime error 1004 with this description:
Run-time error '1004':
The maximum number of data points you can use in a data series for a
2-D chart is 32,000. If you want to use more than 32,000 data points,
you must create two or more series.
There are actually only 4,332 data points in this instance, so my guess
is that Excel is trying to plot the same data points over and over in
the same series on the same chart...that's why the series is redrawn a
few times, until the number of data points exceeds 32,000. What's odd
is that I have no loop in my macro, so I don't understand why the input
data would be stored multiple times in the series collection. Here is
my macro code for reference:
Sub AltPlot()
'
' AltPlot Macro
' Macro recorded 7/6/2004 by Jonathan G. Metts
'
'
Dim TimeRange As Range
Dim AltRange As Range
ChDir _
"C:\Program Files\Microsoft Visual Studio\Common\MSDEV98\My
Projects\msic2003_mod"
Workbooks.OpenText Filename:= _
"C:\Program Files\Microsoft Visual Studio\Common\MSDEV98\My
Projects\msic2003_mod\rangedata.txt" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:= _
Array(Array(0, 1), Array(12, 1), Array(28, 1), Array(44, 1),
Array(60, 1))
Set TimeRange = Worksheets("rangedata").Range("B:B")
Set AltRange = Worksheets("rangedata").Range("C:C")
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SeriesCollection(1).Select
Selection.Delete
ActiveChart.SeriesCollection.NewSeries
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.SeriesCollection(1).XValues = TimeRange
ActiveChart.SeriesCollection(1).Values = AltRange
ActiveChart.Location Where:=xlLocationAsNewSheet,
Name:="MSIC_PlotSheet"
With ActiveChart
..HasTitle = True
..ChartTitle.Characters.Text = "Missile Altitude Plot"
..Axes(xlCategory, xlPrimary).HasTitle = True
..Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time
(sec)"
..Axes(xlValue, xlPrimary).HasTitle = True
..Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Altitude
(ft.)"
End With
ActiveChart.Axes(xlCategory).Select
' With Selection.Border
' .Weight = xlHairline
' .LineStyle = xlAutomatic
' End With
With Selection
..MajorTickMark = xlNone
..MinorTickMark = xlNone
..TickLabelPosition = xlNextToAxis
End With
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlXValues)
..MinimumScaleIsAuto = True
..MaximumScaleIsAuto = True
..MinorUnitIsAuto = True
..MajorUnitIsAuto = True
..Crosses = xlAutomatic
..ReversePlotOrder = False
..ScaleType = xlLinear
..DisplayUnit = xlNone
End With
End Sub
Any ideas?
from imported tabulated data. The chart is generated properly, but it
seems to be drawing itself multiple times, and after several seconds I
get a runtime error 1004 with this description:
Run-time error '1004':
The maximum number of data points you can use in a data series for a
2-D chart is 32,000. If you want to use more than 32,000 data points,
you must create two or more series.
There are actually only 4,332 data points in this instance, so my guess
is that Excel is trying to plot the same data points over and over in
the same series on the same chart...that's why the series is redrawn a
few times, until the number of data points exceeds 32,000. What's odd
is that I have no loop in my macro, so I don't understand why the input
data would be stored multiple times in the series collection. Here is
my macro code for reference:
Sub AltPlot()
'
' AltPlot Macro
' Macro recorded 7/6/2004 by Jonathan G. Metts
'
'
Dim TimeRange As Range
Dim AltRange As Range
ChDir _
"C:\Program Files\Microsoft Visual Studio\Common\MSDEV98\My
Projects\msic2003_mod"
Workbooks.OpenText Filename:= _
"C:\Program Files\Microsoft Visual Studio\Common\MSDEV98\My
Projects\msic2003_mod\rangedata.txt" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:= _
Array(Array(0, 1), Array(12, 1), Array(28, 1), Array(44, 1),
Array(60, 1))
Set TimeRange = Worksheets("rangedata").Range("B:B")
Set AltRange = Worksheets("rangedata").Range("C:C")
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SeriesCollection(1).Select
Selection.Delete
ActiveChart.SeriesCollection.NewSeries
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.SeriesCollection(1).XValues = TimeRange
ActiveChart.SeriesCollection(1).Values = AltRange
ActiveChart.Location Where:=xlLocationAsNewSheet,
Name:="MSIC_PlotSheet"
With ActiveChart
..HasTitle = True
..ChartTitle.Characters.Text = "Missile Altitude Plot"
..Axes(xlCategory, xlPrimary).HasTitle = True
..Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time
(sec)"
..Axes(xlValue, xlPrimary).HasTitle = True
..Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Altitude
(ft.)"
End With
ActiveChart.Axes(xlCategory).Select
' With Selection.Border
' .Weight = xlHairline
' .LineStyle = xlAutomatic
' End With
With Selection
..MajorTickMark = xlNone
..MinorTickMark = xlNone
..TickLabelPosition = xlNextToAxis
End With
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlXValues)
..MinimumScaleIsAuto = True
..MaximumScaleIsAuto = True
..MinorUnitIsAuto = True
..MajorUnitIsAuto = True
..Crosses = xlAutomatic
..ReversePlotOrder = False
..ScaleType = xlLinear
..DisplayUnit = xlNone
End With
End Sub
Any ideas?