作者raymond5566 (雷门56)
看板Office
标题[算表] VBA bug问题
时间Tue Dec 18 18:17:52 2018
软体:excel
版本:office365
小弟想要弄一个能一样本t检定和投报率的vba程式
有时候可以用有时候又不能用
但不晓得为什麽会一直有bug
每次说错的地方都不同
小弟改过一些地方 t=av/(std/a^0.5) 那行会出现型态不符合
Private Sub CommandButton1_Click()
Set r1 = Range(Me.RefEdit1)
Set out_put = Range(Me.RefEdit2)
r = out_put.Row
c = out_put.Column
av = Application.Average(r1)
Sum = Application.Sum(r1)
std = Application.StDev([r1])
roi = (Sum) / 10.1
a = WorksheetFunction.Count(r1)
t = av / (std / a ^ 0.5)
p = 1 - WorksheetFunction.T_Dist(t, a - 1, 1)
Min = WorksheetFunction.Min(r1)
Max = WorksheetFunction.Max(r1)
Cells(r, c) = "Average"
Cells(r, c + 1) = av
Cells(r + 1, c) = "ROI"
Cells(r + 1, c + 1) = roi
Cells(r + 2, c + 1) = std
Cells(r + 2, c) = "s"
Cells(r + 3, c + 1) = t
Cells(r + 3, c) = "t"
Cells(r + 4, c + 1) = p
Cells(r + 4, c) = "p-value"
Cells(r + 5, c + 1) = Min
Cells(r + 5, c) = "Min"
Cells(r + 6, c + 1) = Max
Cells(r + 6, c) = "Max"
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 123.205.64.45
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Office/M.1545128276.A.4DE.html
※ 编辑: raymond5566 (123.205.64.45), 12/18/2018 22:04:49
1F:→ soyoso: 是否是资料有错误值呢?测试如范围内有错误值时会出现如原 12/18 23:36
3F:→ soyoso: 或是范围内的数字为文字型态 12/18 23:41