Hi.
I have tried to build a code for creating an xy scatterplot. I have two columns where the values that I want to plot starts in cells W10 and AC10. The last cell used in the plot may differ from time to time based on manipulation in other parts of the worksheet.
For the values in column AC and W, I want to split it up into three series, series 1 if T >= 51, series 2 if 51 =< T >= 44 and series 3 if 44 =< T >= 17. These three series makes one graph combined.
Here's what I have so far:
When I run this code, the plot appears but only with the last datapoint, where T1 = 51 (cell AC28). The datapoint from cell AC10 to AC27 is not plotted.
I guess you need an if statement but I don't really know how to proceed.
As you can see from the code, I used a Do loop because I tried to make it work for the first series.
any help would be much appreciated!
I have tried to build a code for creating an xy scatterplot. I have two columns where the values that I want to plot starts in cells W10 and AC10. The last cell used in the plot may differ from time to time based on manipulation in other parts of the worksheet.
For the values in column AC and W, I want to split it up into three series, series 1 if T >= 51, series 2 if 51 =< T >= 44 and series 3 if 44 =< T >= 17. These three series makes one graph combined.
Here's what I have so far:
Code:
Sub Reactor_temp()
Dim embeddedchart As Chart
Dim xrange As Range
Dim yrange As Range
Dim i As Long
Dim T1 As Long
T1 = 51 'Tank temperature Series 1
'T2 = 44 ' Tank temperature series 2
'T3 = 17 'Tank temperature series 3
i = 9
Set embeddedchart = ActiveSheet.Shapes.addChart.Chart
With embeddedchart
Do
i = i + 1
Set xrange = Sheets("Reactor Cryst.").Range("AC" & i)
Set yrange = Sheets("Reactor Cryst.").Range("W" & i)
.ChartType = xlXYScatterSmooth
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = xrange
.SeriesCollection(1).Values = yrange
Loop While Range("AC" & i) > T1 And i < 200
End With
End Sub
When I run this code, the plot appears but only with the last datapoint, where T1 = 51 (cell AC28). The datapoint from cell AC10 to AC27 is not plotted.
I guess you need an if statement but I don't really know how to proceed.
As you can see from the code, I used a Do loop because I tried to make it work for the first series.
any help would be much appreciated!