Excel UDF 未出现在下拉菜单中

标签 excel excel-2007 excel-udf vba

我在 Excel 中编写了一个用户定义函数。它工作得很好,没有任何问题。我什至在对象属性菜单下为它写了一个描述。

问题是,当我开始输入函数时,我的 UDF 从未出现在 Excel 下拉菜单中。我希望用户在进入单元格并开始输入函数时能够看到我的 UDF(名为removeNumbers)。

我也希望他们能够看到我写的描述,就像标准的 Excel 函数一样。

最后,有没有一种方法可以为我的函数作为输入的每个参数提供描述?

这是实际的代码,尽管我认为没有必要回答我的问题。

Function removeNumbers(sInput As String, sChoice As Boolean) As String
    Dim sSpecialChars As String
    Dim i As Long

    If (sChoice = True) Then 'if true is selected, will remove all number including 0
    sSpecialChars = "0123456789" 'This is your list of characters to be removed
    For i = 1 To Len(sSpecialChars)
        sInput = Replace$(sInput, Mid$(sSpecialChars, i, 1), "")

    Next
    End If

    If (sChoice = False) Then 'if false is selected, will remove all numbers excluding zero
    sSpecialChars = "123456789" 'This is your list of characters to be removed
    For i = 1 To Len(sSpecialChars)
        sInput = Replace$(sInput, Mid$(sSpecialChars, i, 1), "")

    Next
    End If

    removeNumbers = sInput
End Function

最佳答案

要使该函数显示在下拉列表中,您必须将其放置在标准模块中,而不是工作表代码区域中。

关于Excel UDF 未出现在下拉菜单中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22561422/

相关文章:

vba - 为范围 VBA Excel 中的每个单元格设置偏移值

java - Apache poi XSSF 创建 Excel 文件 - 创建返回空文件,格式或文件扩展名无效?

.net - 从 Excel 中删除功能区

vba - 从一列中提取 5 位数字到另一列

vba - 查找具有特定颜色的范围内的单元格并添加注释

vba - VB 与 VBA 有什么区别?

Excel清理代码VBA

excel - VBA调用网页不打开浏览器不返回数据

vba - excel函数语法调用错误