0

我的代码无法正常工作,并出现一条错误消息,指出检测到不明确的名称: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
4

1 回答 1

3

您定义了 Sub WOS 和功能。只留下其中之一。尝试漫游第一行 Sub WOS()

于 2013-03-25T19:31:13.053 回答