I have a VBA code that generates two colums of data. This analysis repeats to generate more data in the same columns but for different conditions and places this data below the first iteration's output. How do I get the code to generate a XY Scatter with smooth lines next to each block of data generated? My Attempt is below however I run into three problems: 1) It only generates one graph before the debug stops the macro, 2) It generates a barchart and not a scatter 3) How do I get each graph that is generated to be scaled placed next to the data it is drawing from such that I get a column of graphs?
Sub TestExample()
Dim NoIteration As Integer
Dim Iteration As Integer
NoIteration = Range("N26").Value
Dim YieldIteration As Integer
Dim NoOfJumps As Long
Dim minyield As Long
Dim maxyield As Long
Dim jump As Long
NoOfJumps = Range("Q24").Value
minyield = Range("Q25").Value
maxyield = Range("Q26").Value
jump = Range("Q27").Value
Dim xaxis As Range
Dim yaxis As Range
Dim c As Chart
Dim Sh As String
Sh = ActiveSheet.Name
Range("M29:T1000").Select
Selection.Clear
For jump = 0 To NoOfJumps
For Iteration = 0 To NoIteration
'Print Intervals
Range("M30").Offset(NoIteration + Iteration + 4, 0).Value = Range("V19").Value * Iteration
'Solve weights for minimum Spot SD for each given interval
SolverReset
SolverOk SetCell:="$T$18", MaxMinVal:=2, ValueOf:="0", ByChange:="$O$20:$R$20"
SolverAdd CellRef:="$T$17", Relation:=2, FormulaText:=Range("M30").Offset(NoIteration + Iteration + 4, 0).Value
SolverAdd CellRef:="$T$20", Relation:=2, FormulaText:=1
SolverAdd CellRef:="$T$7", Relation:=1, FormulaText:=minyield + jump 'State min required yield
SolverAdd CellRef:="$T$7", Relation:=3, FormulaText:=maxyield + jump 'State max required yield
SolverAdd CellRef:="$O$20:$R$20", Relation:=3, FormulaText:="0"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
'Print Income Return, SD
Range("N30").Offset(Iteration + jump * 50, 0).Value = Range("T7").Value
Range("O30").Offset(Iteration + jump * 50, 0).Value = Range("T8").Value
'Print Spot Return, SD
Range("N30").Offset(NoIteration + Iteration + 4 + jump * 50, 0).Value = Range("T17").Value
Range("O30").Offset(NoIteration + Iteration + 4 + jump * 50, 0).Value = Range("T18").Value
'Print Total Return, SD
Range("N30").Offset(NoIteration * 2 + Iteration + 8 + jump * 50, 0).Value = Range("AC17").Value
Range("O30").Offset(NoIteration * 2 + Iteration + 8 + jump * 50, 0).Value = Range("AC18").Value
Next Iteration
Set yaxis = Range(Range("N30").Offset(Iteration + jump * 50, 0), Range("N30").End(xlDown))
Set xaxis = Range(Range("O30").Offset(Iteration + jump * 50, 0), Range("$O30").End(xlDown))
Set c = ActiveWorkbook.Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:=Sh
'Set c = c.Location(Where:=xlLocationAsObject, Name:="Sheet1")
With c
.ChartType = xlXYScatterLines
' set other chart properties
End With
Dim s As Series
Set s = c.SeriesCollection.NewSeries
With s
.Values = yaxis
.XValues = xaxis
End With
Next jump
End Sub