我想在两个数据点上运行 TTest 公式,但我不断收到错误“无法获取 WorksheetFunction 类的 TTest 属性”。这是我的代码,我哪里出错了?
Sub a()
Dim Z As Double
Z = Application.WorksheetFunction.TTest(Sheet1.Cells(1, 2), Sheet1.Cells(2, 1), 2, 1)
MsgBox "value is " & Z
End Sub
函数的前两个参数TTest
必须是范围/数组。
Sub a()
Dim Z As Double
Dim rng1 As Range
Set rng1 = Range("A1:A2")
Dim rng2 As Range
Set rng2 = Range("B1:B2")
Z = WorksheetFunction.TTest(rng1, rng2, 2, 1)
MsgBox "value is " & Z
End Sub
语法 另请参阅此链接