您可以使用excel引用外部宏吗? [英] Can you refer to an external macro with excel?

查看:322
本文介绍了您可以使用excel引用外部宏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当复杂的宏,需要在多个不同的excel工作表上运行,该宏会定期更新,并且每当进行更改时都需要在每个单独的excel工作表中进行更改.有没有一种方法可以使每个excel文档都引用一个宏?

I have a reasonably complex macro that I need to run on multiple different excel sheets, this macro is updated periodically and whenever a change is made its necessary to change it in each individual excel sheet. is there a way to get each excel document to refer to the one macro?

例如,如果我具有这样的层次结构:

for example if i had a hierarchy like this:

    DOCUMENTS:
       -xlsheet1.xls
       -xlsheet3.xls
       -xlsheet2.xls
       MACROS:
            -macro1.bas

每个工作表中都有一个按钮,当单击该按钮时会运行macro1.

where there was a button in each sheet that ran macro1 when clicked.

推荐答案

我建议将宏移至您的个人文件或创建加载项

I would recommend either moving that macro to your personal file or create an Add-In

使用个人文件

主题:从中央文件部署Excel宏

Topic: Deploy your Excel macros from a central file

链接: 上面链接中的报价:

您是否曾经想过在所有Excel工作表中使用这个非常方便的宏?你可以.本专栏说明如何将宏放置在名为personal.xls的文件中,并在每次启动Excel时使它们可用.

Have you ever wanted to use that really handy macro in all of your Excel worksheets? You can. This column explains how to place your macros in a file called personal.xls and make them available each time you start Excel.

尽管它说它适用于Microsoft Excel 2002,但它适用于所有excel版本.

Though it says that it applies to Microsoft Excel 2002 but it applies to all excel versions.

创建加载项

主题:创建Excel加载项

链接: http://www .ozgrid.com/VBA/excel-add-in-create.htm

上面链接中的报价:

用户经常问我分配宏的最佳方法是什么?"我的答案无疑是通过Excel加载项.毕竟,这是外接程序的作用.对于那些不确定Excel加载项是什么的人,它不过是已另存为加载项,文件>另存为\ Microsoft Excel加载项(* .xla)的Excel工作簿.保存并重新打开后,工作簿将被隐藏,并且只能通过Visual Basic编辑器在项目资源管理器"中看到.它不会以与Personal.xls相同的方式隐藏,因为可以通过Windows> Unhide看到(并使之可见).

I am often asked by users 'what is the best way to distribute their macros?' My answer, is without doubt via an Excel Add-in. After all, this is what Add-ins are for. For those that are not sure what an Excel add-in is, it's is nothing more than an Excel Workbook that has been saved as an Add-in, File>Save as \ Microsoft Excel Add-in (*.xla). Once saved and re-opened the Workbook will be hidden and can only be seen in the "Project Explorer" via the Visual Basic Editor. It is NOT hidden in the same way as the Personal.xls as this can be seen (and made visible) via Windows>Unhide.

这篇关于您可以使用excel引用外部宏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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