在VBA中设置UDF描述时出错 [英] Error while setting UDF description in VBA

查看:67
本文介绍了在VBA中设置UDF描述时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的用户定义功能做一个描述.使用此代码我没有问题:

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

但是当我移至第24个函数并希望对其执行相同操作时,我在最后一行得到以下错误:

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

运行时错误"1004":

Run-time error '1004':

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

Method 'MacroOptions' of object '_Application' failed

这是第24个"RegisterUDF"的代码:

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

推荐答案

说明似乎限制为255个字符.将您的描述缩短11个字符即可解决.

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

这篇关于在VBA中设置UDF描述时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆