Excel VBA 添加自定义函数的参数描述
时间:2023-08-20 10:48:21
在Excel 2010 发布之前,用户已经可以为自定义函数(User-Defined Function)添加一系列的信息,比如描述等等。但是无法用常规的手段为自定义函数的参数添加描述信息。Excel 2010 及以后版本这个问题得到了解决。微软改进了 VBA 中 Application 对象的 MacroOptions 方法——在原来的基础上添加了一个 ArgumentDescriptions 参数,利用此参数就可以为用户自定义函数添加描述信息了。以下给出一个具体例子来说明这个方法的具体应用,将后列的代码复制到一个标准模块中,然后执行其中的 RegUDF 过程,你就可以在 Excel 中使用 FunArgDes 函数了
具体代码:
'用户自定义函数
Function FunArgDes(int1 As Integer, int2 As Integer) As Integer
FunArgDes = int1 + int2
End Function
'此过程用户注册自定义函数
Sub RegUDF()
Dim FuncName As String '函数名称
Dim FuncDesc As String '函数描述
Dim Category As String '函数类别
Dim ArgDesc(1) As String '函数参数描述数组
FuncName = "FunArgDes"
FuncDesc = "返回两个整数的和(测试函数参数描述)"
Category = "函数参数描述测试"
ArgDesc(0) = "函数参数第一个,整型"
ArgDesc(1) = "函数参数第二个,整型"
Call Application.MacroOptions(Macro:=FuncName, Description:=FuncDesc, Category:=Category, ArgumentDescriptions:=ArgDesc)
End Sub
Excel VBA 添加自定义函数的参数描述的下载地址:
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Win8.1系统下将两个磁盘分区合并成一个的方法
![](https://img.aspxhome.com/file/2023/28/a251056_0s.jpg)
Excel表格怎么运用DATEDIF函数
Win10系统总提示RunDLL PWMTR64V.DLL错误怎么办
![](https://img.aspxhome.com/file/2023/28/a245345_0s.jpg)
Win10 Mobile播客应用怎么卸载?
![](https://img.aspxhome.com/file/2023/28/a247533_0s.jpg)
win10如何复制注册表编辑器中某项的路径
![](https://img.aspxhome.com/file/2023/30/a262712_0s.png)
excel解密表格的方法
在Excel表格中怎么统计名字出现次数
WPS 如何让Word只粘贴网页中的文字而自动去除图形和版式
![](https://img.aspxhome.com/file/2023/1/a186291_0s.jpg)
如何在Windows7记事本中修改字体
![](https://img.aspxhome.com/file/2023/27/a233463_0s.jpg)
惠普笔记本重装系统后找不到启动设备怎么办?
![](https://img.aspxhome.com/file/2023/1/a274637_0s.png)
如何在Azure 上搭建基于 Windows Server IIS 的 FTP 服务器
![](https://img.aspxhome.com/file/2023/30/a262911_0s.jpg)
win7系统开机需要长时间才进入桌面
![](https://img.aspxhome.com/file/2023/5/a314615_0s.png)
Win7系统32位和64位有什么区别 32位和64位哪一个更好
![](https://img.aspxhome.com/file/2023/2/a288672_0s.jpg)
win10电脑修改默认浏览器方法
![](https://img.aspxhome.com/file/2023/3/a301851_0s.png)
距离男主自杀还剩七天攻略 距离男主自杀全结局通关流程攻略
![](https://img.aspxhome.com/file/2023/6/a324551_0s.png)
Win10日历显示周数怎么设置?Win10日历显示周数设置方法介绍
![](https://img.aspxhome.com/file/2023/26/a222013_0s.jpg)
如何利用excel快速计算两个日期之间有多少天
怎么在word页眉加图片
![](https://img.aspxhome.com/file/2023/8/34598_0s.png)
win10系统找不到u盘的解决方法
![](https://img.aspxhome.com/file/2023/3/a299736_0s.jpg)
Win10 Your Phone更新:可查看2000张照片
![](https://img.aspxhome.com/file/2023/4/a307845_0s.jpg)