I have a problem with interpolating. When the residuel of a data point (polyline-data point) is 2x standard deviation (allready calculated), then I want reject the data point and it appears red, "rejected" and thick. Then I want to interpolate with the previus and next datapoint.
When 2 datapoints are rejected after each other this no longer goes. When this is the case I want to replace the data point with the polyline value.
I tried to make something, but it runs stuck.
'Now interpolate through
CheckedRow = Headerrows + 1
Do While CheckedRow < NumRows
'Set variables
checkedKP = Cells(CheckedRow, KPColumn)
CheckedValue = Cells(CheckedRow, AfterRejectionEColumn)
If CheckedValue <> "Rejected" Then
'Leave as is
Counter = 1
ElseIf CheckedValue = "Rejected" Then
LastgoodKP = Cells(CheckedRow - 1, KPColumn)
LastgoodTop = Cells(CheckedRow - 1, EastColumn)
LastGoodRow = CheckedRow - 1
NextgoodKP = Cells(CheckedRow + 1, KPColumn)
NextgoodTop = Cells(CheckedRow + 1, AfterRejectionEColumn)
Interprecords = (NextgoodKP - LastgoodKP)
Topdiff = (NextgoodTop - LastgoodTop)
Cells(CheckedRow, AfterRejectionEColumn) = (Counter + 1) * ((Topdiff * (checkedKP - LastgoodKP)) / Interprecords) + LastgoodTop
If CheckedValue + 1 = "Rejected" Then
Cells(CheckedRow, AfterRejectionEColumn) = Cells(CheckedRow, PolyEColumn)
Counter = Counter + 1
End If
End If
CheckedRow = CheckedRow + Counter ' Move on as many as required to get next non rejected value
Loop
Bookmarks