I am creating a Monte Carlo style model for forecasting demand for my company. The model runs as many times as the user requests (needs to be dynamic) and sends back how many "batches" we can expect to manufacture in a given year. I want to plot the results.
I want to include one line per simulation on the chart. However, the number of simulations will change depending on the user's input from another tab, which is titled "control panel".
I have tried to create a loop that will "SetSourceData" dynamically but I have been unsuccessful. Failed code below. Any advice on how to select non-contiguous rows in this fashion would be appreciated.
ThisWorkbook.Worksheets("Charts").Activate
NumberSimulations = ThisWorkbook.Sheets("Control Panel").Cells(28, 3)
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLineMarkers
j = 0
For i = 1 To NumberSimulations
ActiveChart.SetSourceData Source:=Sheets("Batches").Range(Cells(2 + j, 1), Cells(2 + j, 22))
j = j + 7
Next i
The Table that I need to loop over:
Desired Output: