存储和粘贴整个范围

时间:2018-02-26 20:29:43

标签: excel vba excel-vba

所有,我正在尝试进行准montecarlo分析,并且在每次绘制过程中成功地将单个单元格的值存储到数组中,然后再粘贴。但是,当我尝试将整行存储到数组中时,脚本似乎不起作用。希望有人能够提供一些见解,谢谢你的帮助!此问题位于curvearray中的某个位置,即每次绘制时在同一行中复制10个单元格。

Dim randa As Double
Dim stdeva As Double

Dim looprun As Double
Dim arrayone() As Variant
Dim arraytwo() As Variant
Dim curvearray() As Variant

ReDim arrayone(1 To 1)
ReDim arraytwo(1 To 1)
ReDim curvarray(1 To 10)

stdeva = 1
a = Range("baseline").Value

For looprun = 1 To 100

randa = Rnd

Range("baseline").Value = WorksheetFunction.NormInv(randa, a, stdeva)
Application.Calculate

arrayone(UBound(arrayone)) = Range("net").Value
ReDim Preserve arrayone(1 To UBound(arrayone) + 1)

arraytwo(UBound(arraytwo)) = Range("multi").Value
ReDim Preserve arraytwo(1 To UBound(arraytwo) + 1)

curvearray(UBound(curvearray)) = Range("curve").Value
ReDim Preserve curvearray(1 To UBound(curvearray) + 1)

Next looprun

Range("onepaste").Resize(UBound(arrayone)) = Application.Transpose(arrayone)
Range("twopaste").Resize(UBound(arraytwo)) = Application.Transpose(arraytwo)
Range("curvepast").Resize(UBound(curvearray)) = Application.Transpose(curvearray)

End Sub

0 个答案:

没有答案