在VBA中设置UDF描述时出错

时间:2017-05-19 14:37:50

标签: excel vba excel-vba udf

我正在尝试对用户定义的函数进行描述。我使用这段代码没问题:

Sub RegisterUDF23()
Dim FD As String


    FD = "Find the CN value based on landuse and soil type" & vbLf _
    & "CNLookup(Landuse As Integer, SoilType As String) As Integer"

Application.MacroOptions macro:="CNLookup", Description:=FD, Category:=14 _
, ArgumentDescriptions:=Array( _
        "Integer: (1 to 7)", "String: ""A"", ""B"", ""C"", ""D"" ")
End Sub

但是当我转到第24个功能并希望对它做同样的事情时,我在最后一行得到以下错误:

  

运行时错误'1004':

     

对象'_Application'的方法'MacroOptions'失败

这是第24个“RegisterUDF”的代码:

Sub RegisterUDF24()
Dim FD As String

    FD = "friction head loss in feet of water per 100 feet of pipe (ft H20 per 100 ft pipe)" & vbLf _
    & "HWfriction(roughness As Double, flow As Double, hyd_diameter As Double) As Double" & vbLf _
    & "HWfriction = Power(100 / roughness, 1.852) * Power(flow, 1.852) / Power(hyd_diameter, 4.8655) * 0.2083"


Application.MacroOptions macro:="HWfriction", Description:=FD, Category:=14

End Sub

1 个答案:

答案 0 :(得分:4)

Description似乎限制为255个字符。将您的描述缩短11个字符以进行修复。