【发布时间】:2012-04-05 14:32:25
【问题描述】:
我有一个非常简单的 VBA 函数,它接受两个范围参数并使用两个范围的值返回一个双精度值。我在单个单元格的公式栏中使用它,但我想返回一个字符串错误,如果某些东西不太正确。有没有办法在单元格中不显示 #VALUE 的情况下显示它?
Public Function CPP(aPreviousPercentage As Range, aCurrentPercentage As Range) As Double
If (aPreviousPercentage.Value > 0.2) Then
CPP = "Invalid Starting Value"
Exit Function
End If
CPP = aCurrentPercentage.Value - aPreviousPercentage.Value
End Function
【问题讨论】: