ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to keep macros attached when moving sheet to a new workbook (https://www.excelbanter.com/excel-programming/379824-how-keep-macros-attached-when-moving-sheet-new-workbook.html)

[email protected]

How to keep macros attached when moving sheet to a new workbook
 
I need to move sheets back and forth between different workbooks, and I
have no idea how to keep the macros attached to the graphical buttons
on the sheet itself. When I use the buttons (they have macros attached
to add new row), it searches for the old file it came from, even if the
correct macros are attached to the sheet, and I have to re-link the
buttons. Any ideas how to make the path automatically re-assign itself
to the macros in the new workbook?


Dave Peterson

How to keep macros attached when moving sheet to a new workbook
 
You'll have to reassign the buttons to the macros in the new workbook. So those
macros have to be copied over, too.

If you're moving the sheets, you may be able to just dump those controls from
the Forms (?) toolbar and use the commandbuttons from the Control toolbox
toolbar.

The code for these controls lives under the worksheet--so it gets copied when
the sheet gets copied.

wrote:

I need to move sheets back and forth between different workbooks, and I
have no idea how to keep the macros attached to the graphical buttons
on the sheet itself. When I use the buttons (they have macros attached
to add new row), it searches for the old file it came from, even if the
correct macros are attached to the sheet, and I have to re-link the
buttons. Any ideas how to make the path automatically re-assign itself
to the macros in the new workbook?


--

Dave Peterson

Dave Peterson

How to keep macros attached when moving sheet to a new workbook
 
Another option may be to remove the buttons and code completely and add a
toolbar that has icons which run macros against the activesheet.

It may be less work if you ever have to update one of those macros--since they
would only be in one location.

wrote:

I need to move sheets back and forth between different workbooks, and I
have no idea how to keep the macros attached to the graphical buttons
on the sheet itself. When I use the buttons (they have macros attached
to add new row), it searches for the old file it came from, even if the
correct macros are attached to the sheet, and I have to re-link the
buttons. Any ideas how to make the path automatically re-assign itself
to the macros in the new workbook?


--

Dave Peterson


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com