与WorksheetFunctions相关的数组和范围之间有什么区别

时间:2016-06-23 14:57:16

标签: arrays excel vba range

我正在尝试在sub中使用两个工作表函数,对于WorksheetFunction.PercentRank,我可以使用relevant_array,但是当我使用relevant_array WorksheetFunction.CountIf时,我一直收到错误1}}。我希望在.CountIf .PercentRank中使用相同的数组/范围。

Dim y As Variant
Dim z As Variant
        PricePerKG = POCost
        Set ws = ActiveWorkbook.Worksheets("Modified Item Extract")
        Set relevant_Array = ws.Range(ws.Range("B2"), ws.Range("B2").End(xlDown)).SpecialCells(xlCellTypeVisible)
        y = WorksheetFunction.PercentRank(relevant_Array, POCost, 4)
        Percentile = Format(y, "0.00%")

        z = WorksheetFunction.CountIf(relevant_Array, ">" & POCost)
        PriceAbove = z

0 个答案:

没有答案