How to find a data anomaly in a row with a running average?

Ed Harris

New Member
Joined
Dec 9, 2017
Messages
49
Office Version
  1. 2010
Platform
  1. Windows
I have moved from three data points per row to 30 or 80 and my previous solution is no longer good for finding anomalies in the data rows. Because the data often follows a slope looking for a difference from the mean is no longer sufficient. I think I need to look for a difference from a running mean; something like "if the difference between the data point is greater or lesser than the mean of the two cells either side by 0.003 put check or the value in the cell at the end of the row". I am not sure how to program a running mean over the row though. Any help most appreciated.


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
1
2meanmax rowmin rowmax-meanmin-mean
373.3785273.3785973.3787173.3790673.3788973.3788373.3787573.3787173.3786173.3785973.3784673.3784973.3784673.3784773.3783573.3783573.3783173.3783473.3782773.3782473.3782473.378273.3781273.3780673.3780873.3780473.37873.3779573.3988873.377861073.3790873.3988873.377860.0197960.001219check
473.3790773.3791473.3791973.3791273.379173.3790173.3789673.3788673.378873.3787573.378773.3785773.3785373.3784373.3783673.3781173.3782473.378273.3781573.3781173.3780973.3780173.3779373.3778973.3778873.3778673.3778273.3778673.3777873.377770173.3784173.3791973.377770.000780.00064 
573.3778973.3779573.3779873.3779573.3779973.3779973.3778873.3779373.3779873.3780173.37873.37873.3780373.3780873.3780873.3780673.3780873.3780873.3780173.3779173.37873.3780873.3780473.3851173.3781473.3781173.3781473.378273.3781173.378131073.3782673.3851173.377880.0068420.000387check
673.3771973.3772873.3771673.3772273.3772173.3771573.3771873.3769873.37773.3771373.3771473.377373.3772773.3772173.3772573.3772773.3772273.3772973.3773473.3772673.3772773.3772773.377173.3772173.3770773.3772273.3772373.3772273.3772473.37720173.377273.3773473.376980.0001330.000218 
773.3774673.3774873.3773973.3773473.3772473.3771373.3769573.3771373.3771373.3770873.3770873.3770873.3770973.3771773.3771973.3772273.3772773.3772473.3772873.377373.3772573.3772373.3772673.3773573.3772973.3772573.3772473.3770673.3771973.377161073.3772273.3774873.376950.0002640.000271 
Sheet1
Cell Formulas
RangeFormula
AH3:AH7AH3=AVERAGE(A3:AD3)
AI3:AI7AI3=MAX(A3:AD3)
AJ3:AJ7AJ3=MIN(A3:AD3)
AK3:AK7AK3=ABS(AI3-AH3)
AL3:AL7AL3=ABS(AJ3-AH3)
AM3:AM7AM3=IF(OR(AK3 > 0.0015,AL3<-0.0015),"check","")
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
try running this code which will colour cells red which are out of tolerance using the rule you suggested
VBA Code:
Sub test()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 30))
For i = 3 To lastrow
For j = 2 To 29
  mecells = (inarr(i, j - 1) + inarr(i, j + 1)) / 2
  Delta = Abs(mecells - inarr(i, j))
  If Delta >= 0.003 Then
   With Range(Cells(i, j), Cells(i, j)).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
 
  End If
Next j
Next i
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top