我正在尝试使用PERCENTRANK函数来查找“回答”的百分位数'列在' B'列中。从" Dim x As Double"开始是PercentRank函数启动的地方,我只是包含了剩下的代码来显示我正在做的其他事情。
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
答案 0 :(得分:1)
您所看到的是由于PercentRank
适用于数组/范围,而不是地址。
尝试将该行更改为:
x = WorksheetFunction.PercentRank(relevant_array, answer)
那应该解决它。