我的代码无法正常工作,并出现一条错误消息,指出检测到不明确的名称:WOS 下面是我的代码。如何使此代码正常工作?
Sub WOS()
Function WOS(BOP, StartPosn As Range)
Set myRange = Range(StartPosn, StartPosn.End(xlToRight))
Dim lupvals()
ReDim lupvals(1 To myRange.Cells.Count)
i = 1
For Each cll In myRange.Cells
lupvals(i) = Application.Sum(Range(StartPosn, cll))
i = i + 1
Next cll
xx = Application.Match(BOP, lupvals)
If IsError(xx) And lupvals(1) >= BOP Then
WOS = BOP / lupvals(1)
Else
If xx = UBound(lupvals) And (BOP - lupvals(xx)) > 0 Then
WOS = "n/a"
Else
WOS = xx + (BOP - lupvals(xx)) / myRange(xx + 1)
End If
End If
End Function