在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
但是,当我转移到第24function,并希望为此做同样的,我在最后一行得到以下错误:
运行时错误“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
Description
似乎限制为255个字符。 缩短你的描述11个字符来解决它。