Excel UDF不会出现在下拉菜单中

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

问题是,当我开始键入函数时,我的UDF从不出现在显示的Excel下拉菜单中。 我希望用户能够看到我的UDF,名为removeNumbers,当他们进入一个单元格,并开始input一个函数。

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

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

这里是实际的代码,虽然我不认为有必要回答我的问题。

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 

要使该function出现在下拉菜单中,您必须将其放置在标准模块中而不是工作表代码区域中。

另一个海报已经涵盖了需要在一个标准模块的代码。 关于参数说明,您应该查看此答案中的MacroOptions代码 – 尽pipe它只适用于Excel 2010或更高版本。

对于Excel 2007及更早版本,我见过的唯一解决scheme是由JK Pieterse撰写的一篇文章 。 这涉及到使用ExecuteExcel4Macro,看起来有点复杂。