Hi everyone,
I have a summary-type worksheet which has a macro that searches through a much larger sheet and picks out the data that matches certain criteria. The macro spits out the date of the data and the values, next to each other, in cells E4:F4 downwards. This data also has a related minimum spec number.
Currently i am using the below code to plot a line graph of the data over time (note this is a segment of my macro, with Test, Units and Spec being set ealier):
What I would like to do is add a horizontal line with the value of Spec, which is set earlier in the code.
I don't mind having to add another series, or a drawing. As long as it is at the value of spec and is a straight line across the whole time period being plotted.
I hope this is clear enough!
Thanks!
I have a summary-type worksheet which has a macro that searches through a much larger sheet and picks out the data that matches certain criteria. The macro spits out the date of the data and the values, next to each other, in cells E4:F4 downwards. This data also has a related minimum spec number.
Currently i am using the below code to plot a line graph of the data over time (note this is a segment of my macro, with Test, Units and Spec being set ealier):
Code:
Dim Test As String
Dim cht As ChartObject
Dim rng As Range
Dim Units As String
Dim Spec As Double
Set rng = Range(Range("E4:F4"), Range("E4:F4").End(xlDown))
Set cht = ActiveSheet.ChartObjects.Add(******=Range("H7").Left, *******=450, *****=Range("H7").Top, ********=250)
cht.Chart.SetSourceData Source:=rng
cht.Chart.ChartType = xlLine
cht.Chart.HasTitle = True
cht.Chart.ChartTitle.Text = Test
cht.Chart.HasLegend = False
cht.Chart.SeriesCollection(1).MarkerStyle = xlMarkerStyleDiamond
cht.Chart.SetElement (msoElementPrimaryValueAxisTitleRotated)
cht.Chart.Axes(xlValue, xlPrimary).AxisTitle.Text = Units
What I would like to do is add a horizontal line with the value of Spec, which is set earlier in the code.
I don't mind having to add another series, or a drawing. As long as it is at the value of spec and is a straight line across the whole time period being plotted.
I hope this is clear enough!
Thanks!