summaryrefslogtreecommitdiff
path: root/outlier.vba
blob: 0dbfe7cb9799b8789074b563c1efb086978eaf18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option VBASupport 1
Option Compatible
Function OUTLIER(range As Variant, value As Double) As Boolean
	Dim q1 As Double
	Dim q3 As Double
	Dim iqr As Double
	Dim max As Double
	Dim min As Double

	q1 = WorksheetFunction.QUARTILE(range, 1)
	q3 = WorksheetFunction.QUARTILE(range, 3)
	iqr = q3 - q1
	max = iqr*1.5 + q3
	min = q1 - iqr*1.5
	If (value < min) Or (value > max) Then
		OUTLIER = 1
	Else
		OUTLIER = 0
	End If
End Function