J
John Michl
I'm trying to write a macro that will fill a data series based on a
single value in a spreadsheet. In this example, Series 1 is the actual
observation data. Series 2 would be the average for all points in
Series 1. My code works fine as long as the series average is rounded
to zero decimal places. If not, I receive the error "Subscript out
of Range". I've tried declaring "i" as various data types to no avail.
Help would be appreciated.
Sub AddAverageLine()
'Populate GrandMean values
Dim ar As Variant
ReDim ar(1 To p)
p = ActiveChart.SeriesCollection(1).Points.Count
i = Round(Range("GrandMean"), 0) 'WANT THIS TO 2 DECIMALS NOTE 0
For x = 1 To UBound(ar)
ar(x) = i
Next x
ActiveChart.SeriesCollection(2).Values = ar
End Sub
- John
single value in a spreadsheet. In this example, Series 1 is the actual
observation data. Series 2 would be the average for all points in
Series 1. My code works fine as long as the series average is rounded
to zero decimal places. If not, I receive the error "Subscript out
of Range". I've tried declaring "i" as various data types to no avail.
Help would be appreciated.
Sub AddAverageLine()
'Populate GrandMean values
Dim ar As Variant
ReDim ar(1 To p)
p = ActiveChart.SeriesCollection(1).Points.Count
i = Round(Range("GrandMean"), 0) 'WANT THIS TO 2 DECIMALS NOTE 0
For x = 1 To UBound(ar)
ar(x) = i
Next x
ActiveChart.SeriesCollection(2).Values = ar
End Sub
- John