raulsanchez
New Member
- Joined
- Nov 19, 2013
- Messages
- 8
Hi everybody,
I have a quadrant graph that contains 7 series, and I have been plotting XY Scatter points (starting at series 8 and increasing until the last of the data set is plotted) in the graph using VBA in Excel 2010. I now have one machine running on Excel2013, and the code that has run flawlessly on Excel2010 is generating plotting errors when used with Excel2013.
When the subroutine is assigning XValues and Values, the data points are not being assigned to the series. In the formula bar, each series is showing it's name and series number, but no X or Y coordinates.
I am curious if anybody else has stumbled upon this situation. Below is my code for the plotting.
Specifically, the following lines seem to be recognizing what the data points are, but they are not getting passed to the series formula.
Any insight that could be shared is greatly appreciated. Thank you!!
I have a quadrant graph that contains 7 series, and I have been plotting XY Scatter points (starting at series 8 and increasing until the last of the data set is plotted) in the graph using VBA in Excel 2010. I now have one machine running on Excel2013, and the code that has run flawlessly on Excel2010 is generating plotting errors when used with Excel2013.
When the subroutine is assigning XValues and Values, the data points are not being assigned to the series. In the formula bar, each series is showing it's name and series number, but no X or Y coordinates.
I am curious if anybody else has stumbled upon this situation. Below is my code for the plotting.
Code:
Sub Plot_Chart()
Dim wsData As Worksheet
Dim wsChart As Worksheet
Dim wsControl As Worksheet
Dim lngStartRow As Long
Dim lngLastRow As Long
Dim lngCounter As Long
Dim strLabelRevenue As String
Dim n As Long
Set wsData = Sheet9
Set wsChart = Sheet3
Set wsControl = Sheet4
lngStartRow = 11
lngLastRow = wsData.Cells(Rows.Count, 2).End(xlUp).Row
lngCounter = 8
wsChart.Activate
ActiveSheet.ChartObjects(1).Activate
'remove previous series
For n = ActiveChart.SeriesCollection.Count To lngCounter Step -1
ActiveChart.SeriesCollection(n).Delete
Next n
With ActiveChart.Axes(xlCategory, xlPrimary)
.MaximumScale = 1
.MinimumScale = 0
.MajorUnit = 0.5
End With
'reload chart with new series
For n = lngStartRow To lngLastRow
strLabelRevenue = Format(wsData.Cells(n, 3), "$0,000")
With ActiveChart
With .SeriesCollection.NewSeries
.ChartType = xlXYScatter
.XValues = wsData.Cells(n, 5)
.Values = wsData.Cells(n, 15)
.Name = wsData.Cells(n, 2)
.AxisGroup = 1
.ApplyDataLabels Type:=xlDataLabelsShowLabel, _
AutoText:=True, LegendKey:=False
With .Points(1)
.DataLabel.Text = wsData.Cells(n, 2) & " - " & strLabelRevenue
.Interior.Color = vbRed
.MarkerStyle = xlMarkerStyleCircle
.MarkerSize = 13
End With
End With
With .SeriesCollection(lngCounter).DataLabels
.VerticalAlignment = xlCenter
.Position = xlLabelPositionAbove
.Orientation = xlHorizontal
.AutoScaleFont = False
.Font.Size = 10
.Font.Bold = False
.Font.ColorIndex = 0
End With
End With
lngCounter = lngCounter + 1
Next n
End Sub
Specifically, the following lines seem to be recognizing what the data points are, but they are not getting passed to the series formula.
Code:
.XValues = wsData.Cells(n, 5)
.Values = wsData.Cells(n, 15)
Any insight that could be shared is greatly appreciated. Thank you!!