Error while setting UDF description in VBA

孤街浪徒 提交于 2019-12-12 04:36:09

问题


I am trying to Make a description for my user defined functions. I had no problem using this code:

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

But When I moved to 24th function and wanted to do the same for it, I get the following error on last line:

Run-time error '1004':

Method 'MacroOptions' of object '_Application' failed

Here's the code for the 24th "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:


The Description appears to be limited to 255 characters. Shorten your description by 11 characters to fix it.



来源:https://stackoverflow.com/questions/44072840/error-while-setting-udf-description-in-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!