Copy a worksheet to a new workbook and have a button point to the macro in the NEW workbook?

爱⌒轻易说出口 提交于 2019-12-02 23:10:10

问题


I have a worksheet that looks like a form. It has a "Reset" button to clear the values.

There is a macro that I can run that copies that sheet into a new Workbook and emails it to someone. The module that contains the macros gets copied into it and all is almost ok. The problem is, the button on the worksheet that runs the reset macro still points back to the original document. How can I have it point to the macro within itself?

Edit: One thing to point out is that I do have macros within that sheet that fire off if cells are changed. Those work great and don't try and load the original file. It's just the ones within the button that don't work.


回答1:


You should use 'ActiveX form button' instead of 'simple form button' (which I guess you use). Then you have to put reset procedure within ActiveX button event (double click on it to edit that procedure). As the result of coping the sheet both button and the procedure would be moved to new workbook which will break any reference to original file.



来源:https://stackoverflow.com/questions/15392447/copy-a-worksheet-to-a-new-workbook-and-have-a-button-point-to-the-macro-in-the-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!