lewisgmorris
Board Regular
- Joined
- Oct 23, 2014
- Messages
- 119
Hi All,
I have wrote the following function from what i have read online to mark all the data that is outside the "normal" values of the range.
Data source on google docs sheet here - https://drive.google.com/file/d/0B6BOCseXW1yZMEdELXpIazd5OFk/view
Only problem is that it doesn't seem to take into account times a value is found in the range. I would have expected at least the 500's to not be an outlier
Any one have a better solution to attack this issue? Or see where I may have gone wrong with my code?
p.s this function does work on smaller data sets quite well.
I have wrote the following function from what i have read online to mark all the data that is outside the "normal" values of the range.
Data source on google docs sheet here - https://drive.google.com/file/d/0B6BOCseXW1yZMEdELXpIazd5OFk/view
Only problem is that it doesn't seem to take into account times a value is found in the range. I would have expected at least the 500's to not be an outlier
Any one have a better solution to attack this issue? Or see where I may have gone wrong with my code?
p.s this function does work on smaller data sets quite well.
Code:
Sub changeOutlier1()
Dim dblAverage As Double, dblStdDev As Double
Dim ws As Worksheet
Set ws = Worksheets("Stock Detail Use")
Dim lr, x As Integer
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row
Dim rng As Range
Set rng = ws.Range(ws.Cells(2, 2), ws.Cells(lr, 2))
ws.Range("C:C").ClearContents
dblAverage = WorksheetFunction.Average(rng)
dblStdDev = WorksheetFunction.StDev_P(rng)
Dim q1, iqr, q3 As Double
q1 = WorksheetFunction.Quartile(rng, 1)
q3 = WorksheetFunction.Quartile(rng, 3)
iqr = q3 - q1
For x = 2 To lr
If ws.Cells(x, 2) < q1 - (1.5 * iqr) Or ws.Cells(x, 2) > q1 + (1.5 * iqr) Then
ws.Cells(x, 3) = True
End If
Next x
End Sub