ワークシート関数は、頭にWorksheetFunctionまたはApplicationをつけると使えます。
例外的に使えないものもあります。(既にVBAに同等の機能がある場合(例:Left,Mid等))
WorksheetFunctionまたはApplicationではエラーに関する挙動が異なります。(調べてみて下さい)
参考コードを挙げておきます。
Sub test1()
Dim lastRow As Long
Dim former As Long
Dim startRow As Long
Dim rng As Range
Dim k As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
former = Cells(2, "A")
startRow = 2
For k = 3 To lastRow + 1
If Cells(k, "A") <> former Then '新しい商品CD
Set rng = Range(Cells(startRow, "B"), Cells(k - 1, "B"))
Cells(k - 1, "C") = Application.TrimMean(rng, 0.2)
former = Cells(k, "A")
startRow = k
End If
Next
End Sub