davidmnix
01-18-2017, 09:04 PM
So I created the i loop and managed to get a single series to plot as its supposed to, but now I need to run the same function using different j values and add a new series to the chart for each j. How do I do that? Everything I've tried so far either creates 5 separate charts or doesn't run.
Any help is greatly appreciated. Below is a segment from my code. I removed all the attempts I had previously made at having the j loop create the series.
For j = 1 To 1.2 Step 0.05
Tr(j) = Tc * j
For i = 1 To 150
P(i) = i
Z(i) = PR_Z_Solve(Tr(j), Pc, w, P(i), V)
Next i
Next j
Dim Plot As Chart
Set Plot = ActiveWorkbook.Charts.Add
Dim Series As Series
Set Series = ActiveChart.SeriesCollection.NewSeries
With ActiveChart
With Series
.ChartType = xlXYScatterLinesNoMarkers
.XValues = P
.Values = Z
End With
With ActiveChart
.Name = TabName
.HasLegend = False
With .PlotArea.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
End With
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Z"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "P"
.Axes(xlCategory).MinimumScale = 1
.Axes(xlCategory).MaximumScale = 150
.Axes(xlValue).MinimumScale = 0
.Axes(xlValue).MaximumScale = 1
.ChartArea.Format.TextFrame2.TextRange.Font.Name = "Times New Roman"
.ChartArea.Format.TextFrame2.TextRange.Font.Size = 18
End With
Any help is greatly appreciated. Below is a segment from my code. I removed all the attempts I had previously made at having the j loop create the series.
For j = 1 To 1.2 Step 0.05
Tr(j) = Tc * j
For i = 1 To 150
P(i) = i
Z(i) = PR_Z_Solve(Tr(j), Pc, w, P(i), V)
Next i
Next j
Dim Plot As Chart
Set Plot = ActiveWorkbook.Charts.Add
Dim Series As Series
Set Series = ActiveChart.SeriesCollection.NewSeries
With ActiveChart
With Series
.ChartType = xlXYScatterLinesNoMarkers
.XValues = P
.Values = Z
End With
With ActiveChart
.Name = TabName
.HasLegend = False
With .PlotArea.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
End With
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Z"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "P"
.Axes(xlCategory).MinimumScale = 1
.Axes(xlCategory).MaximumScale = 150
.Axes(xlValue).MinimumScale = 0
.Axes(xlValue).MaximumScale = 1
.ChartArea.Format.TextFrame2.TextRange.Font.Name = "Times New Roman"
.ChartArea.Format.TextFrame2.TextRange.Font.Size = 18
End With