excel - 如何在没有额外操作的情况下在所有 excel 中使用用户定义的函数?

标签 excel vba user-defined-functions

我有一个简单的函数,可以将范围转换为 CSV 格式。我每次都在每个 excel 文件中使用这个函数。所以我需要这个函数默认存在于所有 Excel 工作簿中,不需要额外加载作为 Excel 的 默认公式(例如 VLookUp)。我该怎么做?

模块中的用户定义函数:

Public Function csvformat(r As range, seperator As String)
result = ""
For Each cell In r
result = result & cell & seperator
Next
result = Left(result, Len(result) - 1)
csvformat = result
End Function

最佳答案

发件人:https://support.office.com/en-us/article/Create-Custom-Functions-in-Excel-2007-2f06c10b-3622-40d6-a1b2-b6748ae8231f?ui=en-US&rs=en-US&ad=US&fromAR=1

An easier way to make your custom functions available at all times is to store them in a separate workbook and then save that workbook as an add-in. You can then make the add-in available whenever you run Excel. Here’s how to do this:

After you have created the functions you need, click the Microsoft Office Button, and click Save As.

In the Save As dialog box, open the Save As Type drop-down list, and select Excel Add-In. Save the workbook under a recognizable name—such as MyFunctions—in the AddIns folder. (The Save As dialog box will propose that folder, so all you need to do is accept the default location.)

After you have saved the workbook, click the Microsoft Office Button, and click Excel Options.

In the Excel Options dialog box, click the Add-Ins category.

In the Manage drop-down list, select Excel Add-Ins. Then click the Go button.

In the Add-Ins dialog box, select the check box beside the name you used to save your workbook, as shown below.

关于excel - 如何在没有额外操作的情况下在所有 excel 中使用用户定义的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42562996/

相关文章:

VBA - 从动态创建的 ListView 中将项目添加到组合框

sql - 用户定义函数 - Northwind 数据库 - Employee_Name 函数

vba - Excel自动计算设置

python - Spark-Submit 的 pickle 错误 "_pickle.PicklingError: args[0] from __newobj__ args has the wrong class"

Excel 说 no "End Sub",只需移动光标就会崩溃

performance - Excel 2003 : Why does creating links to other spreadsheets take so long?

excel - 对象变量或 with block 未设置 -

vba - 命名图表时出现内存不足错误

excel - SSRS 2008 R2 - 导出到 Excel 时的 MAX TABS

VBA:仅考虑 A 中最后一个单元格的值并将选择范围扩展到 W