Error while setting UDF description in VBA

2019-09-15 02:28发布

问题:

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.