Monte Carlo simulation - cut and paste values into separate worksheet

piercebrosnan

New Member
Joined
Jun 19, 2013
Messages
4
Hello,
I am trying to develop a monte carlo simulation that creates a data table based on the number of simulations stated. For each iteration done I would like excel to copy a specified column range between B10 to B1010 in one worksheet named "Dataset" and value paste these column values in a separate worksheet named "Simulation" in a row range say B10:B1010 in the Simulation worksheet before it goes on to the next iteration to generate another set of random numbers to perform the same task but now pasting the next iteration in a column next to the previously generated values in Simulation tab. After n iterations, excel should have a unique column of randomly generated numbers for that range.

I have tried the code below but keeping getting the top row of values repeated in each column.

Could you please assist me? This was also posted on Monte Carlo simulation - cut and paste values into separate worksheet

Thanks in advance. This is the code I tried but not getting the results I am looking for.

Code:
Sub run()      Dim iter As Long, r As Long, NoCols As Long      Dim i As Double      Dim myRange As Range             'Start real macro      'loop through for our count of iterations     iter = ThisWorkbook.Sheets("Dataset").Range("D5")            For i = 1 To iter          Application.Calculate          ThisWorkbook.Sheets("Dataset").Cells(55, 13) = ThisWorkbook.Sheets("Dataset").Range("BC11")                Next i            With Sheets("Dataset")          Set myRange = .Range("B10:B1010", .Range("B10:B1010").End(xlToRight))          NoCols = myRange.Columns.Count      End With      Application.ScreenUpdating = False      For r = 2 To 2 + iter - 1          myRange.Calculate          Sheets("Simulation").Cells(r, "D").Resize(, NoCols).Value = myRange.Value      Next r      Application.ScreenUpdating = True  End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,945
Messages
6,127,856
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top