See attached file. Current logic:
For every iteration a random value is selected with formula in cell E3 and copied to next free cell in Column G.
What I want to add is the following:
User selects number of iterative steps in cell E1 and number of forecast periods in cell E2, e.g. 6. In this case for every iteration 6 random values will be selected by formula in cell C3 and from that 6 the average must be calculated. This average value will be copied into the next free cell of column G. The step from selecting number of random values, calculating average of that and placing into the next free cell of column G will be iterative to value of cell E1.
Problem is that I am not able to get the correct vba code.......

Sub Randomnumber()
Application.ScreenUpdating = False
Range("E3").Name = "Source"
Columns("G").Clear
Range("G1").Value = "Values"
Iteraties = Range("E1").Value
teller = 1
Do While teller <= Iteraties
Range("Source").Copy
Range("Destination").Offset(teller - 1, 0).PasteSpecial (xlValues)
teller = teller + 1
Loop
Application.CutCopyMode = False
Application.ScreenUpdating = True
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
MsgBox ("Calculation is ready and pivottable is updated")
End Sub
Bookmarks