我试图排除在Excel中均值上下两个标准偏差的值。数据集很大。我可以用来自动执行的Excel或公式中的任何函数?请注意,Excel的版本为2007。最好清除那些单元格
答案 0 :(得分:0)
假设我们在 B 列中有数据,例如:
(明显标记了异常值)
运行这个小宏:
Sub OutlierKiller()
Dim I As Long, N As Long, wf As WorksheetFunction
Dim U As Double, L As Double, v As Double
Set wf = Application.WorksheetFunction
N = Cells(Rows.Count, "B").End(xlUp).Row
U = wf.Average(Range("B:B")) + 2 * wf.StDev_S(Range("B:B"))
L = wf.Average(Range("B:B")) - 2 * wf.StDev_S(Range("B:B"))
For I = 1 To N
v = Cells(I, 2).Value
If v >= U Or v <= L Then Cells(I, 2).Clear
Next I
End Sub
将产生:
您需要调整代码以匹配您的数据结构。