I think it shouldn't goes this way. Cut off 25% of bottom results and 25% of top results as result not a result value. So you can't set criteria 14% and 20% to cut off (as I understand).
I've prepared something in VBA like this:
Put into standard module:
Sub MyCalc()
Dim cell As Range
Dim temp() As Variant
Dim MyVal2() As Variant
Dim i, j As Long
i = 0
j = 0
For Each cell In [B4:B150]
If cell.Value = [D1].Value Then
ReDim Preserve temp(i)
temp(i) = cell.Offset(0, 1).Value
i = i + 1
End If
Next cell
For i = ((UBound(temp) + 1) * 0.25) To ((UBound(temp) + 1) * 0.75 - 1)
ReDim Preserve MyVal2(j)
MyVal2(j) = temp(i)
j = j + 1
Next i
[D2].Value = Application.WorksheetFunction.Average(MyVal2)
[E2].Value = Application.WorksheetFunction.Min(MyVal2)
[F2].Value = Application.WorksheetFunction.Max(MyVal2)
End Sub
and into code of Sheet1 or Sheet2 (check attached file):
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [D1]) Is Nothing Then
Range("$A$3:$C$121").AutoFilter Field:=2, Criteria1:=[D1].Value
Call MyCalc
End If
End Sub
imho works correctly.
Bookmarks