VBA趋势返回值

时间:2016-11-11 11:59:25

标签: arrays vba excel-vba trend excel

我在VBA中定义了两个数组,我希望根据已知值通过线性插值点找到。

Sub example()
Dim boundpoint(1 To 2) As Integer
Dim boundeleva(1 To 2) As Double
Dim totELEV as Integer
ReDim plvl(201) as Double
Dim out As Variant
totELEV = 12
boundeleva(1) = -61.90
boundeleva(2) = -260.25
boundpoint(1) = 1
boundpoint(2) = 201

    For i = 1 to totELEV
        out = Application.WorksheetFunction.Trend(boundPoint,boundEleva,ELEV(i),True)
        plvl(i) = Application.WorksheetFunction.RoundUp(out,0)
    Next i

End Sub

但当然由于不匹配而无法正常工作。如果我理解正确,“趋势”将为每个ELEV(i)返回一个数组。 现在我只想让返回的值为Double,可以向上舍入到最接近的整数。

有什么建议吗?

谢谢!

0 个答案:

没有答案