Application.WorksheetFunction.Log无效

时间:2016-05-19 08:14:31

标签: vba excel-vba excel

任何人都可以帮助我使用十进制对数吗? 怎么可能一个常数都可以,但另一个不计算(即使是相同的公式)?非常感谢

    Dim SumaLpi(1 To 22) As Double 'suma(10^(0.1Lpi))
    Dim Lp_stredni(1 To 22) As Double
    Dim Lw(1 To 22) As Double
    Dim p(0 To 100) As Double
    Dim Lpi(0 To 100) As Double
    Dim Konst As Double

    Konst = 0.0000000004

    For i = 1 To 22
    SumaLpi(i) = 0
        For j = 1 To N
                p(j) = Cells(5 + j, i + 3) / Konst
                Lpi(j) = 10 * Application.WorksheetFunction.Log(p(j))
                SumaLpi(i) = SumaLpi(i) + 10 ^ (0.1 * Lpi(j))
        Next j
    Lp_stredni(i) = 10 * Application.WorksheetFunction.Log(1 / N * SumaLpi(i)) 
         'Lp_stredni(i) WORK WELL
    Lw(i) = 10 * Application.WorksheetFunction.Log(1 / N * SumaLpi(i)) 
         'Lw(i) 'DOESN´T WORKING
    Cells(4, 3 + i) = Lp_stredni(i)
    Next i

1 个答案:

答案 0 :(得分:0)

p(j)数组很可能具有较高的值,因为您通过" Konst"来分配您的单元格的内容。 (这是0.0000000004),但在你的例子中,你使用了一个" Double"类型。 我认为你应该使用"整数"或"长"