我的代码无法正常显示错误消息,指出检测到模糊名称: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
答案 0 :(得分:3)
您定义了Sub WOS和功能。只留下其中一个。尝试漫游第一行Sub WOS()