Excel VBA参数不可选

我正在尝试在Excel中编写一套VBA程序。 该过程的目的是查看表中的数据,对特定列中的值求平均值,然后突出显示每个高于平均值的值。

我的困境是,当我尝试运行我的代码时,我不断收到“参数不可选”错误。 我完全理解这个错误通常会表明什么。 但是,我不明白为什么这两个string我没有被接受? 提前感谢任何帮助..

Sub HighlightLarge() Call HighlightProductOrders(">", "vbYellow") End Sub Sub HighlightProductOrders(FunctionType As String, HighlightColor As String) 'Delete all previous conditional formatting Cells.FormatConditions.Delete 'Make a variable to dynamically cover an entire table range Dim FormatTable As Range Set FormatTable = Range(Range("AllOrders").Offset(1, 0), Range("AllOrders").End(xlDown).End(xlToRight)) 'Make a variable to calculate average order quantity Dim AverageQuantity As Double AverageQuantity = Application.WorksheetFunction.Average(FormatTable.Columns(2)) 'Perform Highlighting based on Sub's params Dim i As Integer i = 1 If FunctionType = ">" Then Do Until Range("AllOrders").Offset(i, 0) = "" If Range("AllOrders").Offset(i, 1) > AverageQuantity Then Range("AllOrders").Offset(i, 0).Interior.Color = HighlightColor Range("AllOrders").Offset(i, 1).Interior.Color = HighlightColor Range("AllOrders").Offset(i, 2).Interior.Color = HighlightColor End If Loop ElseIf FunctionType = "<" Then Do Until Range("AllOrders").Offset(i, 0) = "" If Range("AllOrders").Offset(i, 1) < AverageQuantity Then Range("AllOrders").Offset(i, 0).Interior.Color = HighlightColor Range("AllOrders").Offset(i, 1).Interior.Color = HighlightColor Range("AllOrders").Offset(i, 2).Interior.Color = HighlightColor End If Loop Else MsgBox "Parameters were not as expected.", vbCritical, "Error!" Exit Sub End If End Sub