I have been searching for similar questions and haven't found this specific one, so apologies if it has already been asked.
I am trying to backtest an idea in finance and run 100's of simulations. My intention is to add a row (or just a range of cells in a row) of preset values into the next empty row in a data set. Based on the random number that is generated in cell "A1", 1-9, it should select a specific row and copy/paste or offset the data into the next empty row. Then the timer ticks down, and restarts.
What is below works, but requires me to hand enter each cell origin to cell destination, and I would need 40+ cells for each of the (1-9 possibilities of the randomization). So that would be a lot of hard coding. There has to be a better way.
Thanks in advance.
Sub CD1()
start_value = WorksheetFunction.RandBetween(1, 9)
Range("A1") = start_value
If Range("A1") < 5 Then
Range("c5000").End(xlUp).Offset(1, 0) = Range("c6").Value
Range("d5000").End(xlUp).Offset(1, 0) = Range("d6").Value
Range("e5000").End(xlUp).Offset(1, 0) = Range("e6").Value
Range("f5000").End(xlUp).Offset(1, 0) = Range("f6").Value
End If
Application.OnTime Now + TimeValue("00:00:03"), "Sheet5.CD1"
End Sub
Dim CurrentRow As Long: CurrentRow = Cells(Rows.Count, "C").End(xlUp).Offset(1).Rowand continue withRows(CurrentRow).Columns("C:AZ").Value = Range("C6:AZ6").Value. If you mean something else, explain in more detail.