Hello All,
I have 3 columns:
| A | X | Y |
| 0 | 59 | 61 |
|20 | 58 | 60 |
|110| 59 | 60 |
I want to add a series (a subset of data from columns X and Y) to my scatter plot based only on rows where the value in column A is <101.
(The subset I want is Bolded above)
This is way over my head.
A little help would be much appreciated.
Thanks in advance.
Robert
My code fails at the second to last line.
Runtime error '-2147221080 (800401a8)
The specified dimension is not valid for the current chart type
Thoughts?
I have 3 columns:
| A | X | Y |
| 0 | 59 | 61 |
|20 | 58 | 60 |
|110| 59 | 60 |
I want to add a series (a subset of data from columns X and Y) to my scatter plot based only on rows where the value in column A is <101.
(The subset I want is Bolded above)
This is way over my head.
A little help would be much appreciated.
Thanks in advance.
Robert
Code:
shtName = ActiveSheet.Name
' check for values < 101
Dim notps As Integer
Dim lowtps As Integer
tps = Range("B2").Value
lowtps = Range("B3").Value
If tps > 0 Or lowtps > 0 Then
'Set Ranges
Dim XRng As Range
Dim YRng As Range
Dim LastRow As Long
Dim i As Long
LastRow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 1 To LastRow
If Cells(i, "G").Value < 101 Then
If XRng Is Nothing Then
Set XRng = Cells(i, "U")
Set YRng = Cells(i, "V")
Else
Set XRng = Union(XRng, Cells(i, "U"))
Set YRng = Union(YRng, Cells(i, "V"))
End If
End If
Next i
End If
' add scatterplot
Charts.Add
With ActiveChart
.ChartType = xlXYScatter
.SetSourceData Source:=Range( _
"'" + shtName + "'!U:V")
.HasLegend = False
.SeriesCollection(1).HasDataLabels = False
.Location Where:=xlLocationAsObject, Name:=statSht
.FullSeriesCollection(2).XValues = XRng
.FullSeriesCollection(2).Values = YRng
End With
My code fails at the second to last line.
Runtime error '-2147221080 (800401a8)
The specified dimension is not valid for the current chart type
Thoughts?
Last edited: