【问题标题】:When running PERCENTRANK I receive the "Unable to get the PercentRank property of the WorksheetFunction class" error运行 PERCENTRANK 时,我收到“无法获取 WorksheetFunction 类的 PercentRank 属性”错误
【发布时间】:2016-10-17 00:45:31
【问题描述】:

我正在尝试使用 PERCENTRANK 函数来查找“答案”在“B”列中排名的百分位数。 PercentRank 函数从“Dim x As Double”开始,我只包含其余代码以显示我还在做什么。

  Dim response As VbMsgBoxResult
    response = MsgBox("Is This Item Catch Weight?", vbYesNo)
  If response = vbNo Then
    Dim cost, weight, answer As Variant
    Dim myrng As Range
        cost = InputBox("Please Enter PO Cost")
        weight = InputBox("Please Enter Net Weight")
        answer = cost / weight
        MsgBox "Price per KG is: " & answer
        Dim x As Double
            Set ws = ActiveWorkbook.Worksheets("Sheet1")
            Set relevant_array = ws.Range(ws.Range("B1"), ws.Range("B1").End(xlDown))
            x = WorksheetFunction.PercentRank(relevant_array.Address, answer)
            Debug.Print x
        Exit Sub

【问题讨论】:

    标签: excel vba macros percentile


    【解决方案1】:

    您所看到的是因为PercentRank 适用于数组/范围,而不是地址。

    尝试将该行更改为:

    x = WorksheetFunction.PercentRank(relevant_array, answer)
    

    这应该可以解决它。

    【讨论】:

    • @cam,您是否直接在电子表格中尝试过? relevant_arrayanswer 中的值是什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2013-10-17
    • 1970-01-01
    相关资源
    最近更新 更多