Filling Source Data Array with Decimal Values
Thanks, Kelly. This will be helpful.
In my case, I already had the chart set up but just needed to change
some of the values. I did not want to have extra data ranges in the
worksheet to create the horizontal lines. After pulling my hair out, I
decided to write a little code that would create string which would
look like an array that could be put into the X Values area of the
chart. I attached this code to the Chart Activate event so that every
time I click on the chart, the lines will redraw based on current
information.
Private Sub Chart_Activate()
Dim strValues 'string that represents array of values in format "={x,
x, x, x}
p = ActiveChart.SeriesCollection(1).Points.Count
'Populate GrandMean values
strValues = "={" & Round(Range("GrandMean"), 2)
For x = 1 To p - 1
strValues = strValues & ", " & Round(Range("GrandMean"), 2)
Next x
strValues = strValues & "}" 'add closing }
ActiveChart.SeriesCollection(2).Values = strValues
End Sub
- John
|