在 ExcelVBA 中重新计算并在每次模拟中存储输出

Recalculation in ExcelVBA and Storing output in each simulation

我想将每次模拟的值存储在 C1012 中,从 1 到 1000。 我正在重新计算 Worksheet MC 的整个 C 列。 我必须将 Simulation 的值存储在 BF 列中 我写了代码,但它没有给出任何输出。

Dim i As Integer

对于 i = 1 到 1000

SimulationArray(i) = Cells(1012, 3).Value
Worksheet(MC).Column(C).Calculate

下一个

Sheets("MC").Range("BF1:BF1000") = SimulationArray

请帮忙。谢谢

试试这个:

Sub trythis()
Dim SimulationArray(1 To 1000)
Dim i As Integer
For i = 1 To 1000

    SimulationArray(i) = Cells(1012, 3).Value
    Sheets("MC").Range("C:C").Calculate
Next i

Sheets("MC").Range("BF1:BF1000").Value = Application.Transpose(SimulationArray)

End Sub