VBA code to copy to change button macros

tobyz95

Board Regular
Joined
Jul 28, 2012
Messages
190
Hi ALL, I am wondering if there is any easy way to change the assigned macro of buttons on a worsheet when creating a new worksheet saved under new name.

I have a workbook with 15 sheets that have 33 buttons, and 2 Command buttons on each. This is a yearly workbook. When I copy Template and create the 15 sheets to the new year workbook,
All the buttons still refer to last years workbook macros. So I have to click on each one manually and assign the new year workbook macros to each button.

Looking for an easier way?

Thanks for any help!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This info about sharing code over a set of users might get you started with something that's for sharing over workbooks instead. I didn't study the whole thing, but the idea of a "common" project might be what you need.

You can string together what looks like a project name using
VBA Code:
Dim wb As Workbook

Set wb = Application.ThisWorkbook
wb.VBProject.Name & " (" & wb.Name & ")"
but somehow I doubt that would be useful to you.
 
Upvote 0
Thank you for responding, yeah I don't believe that is the answer..thanks so much for trying though!
 
Upvote 0
UPDATE: The answer was there the whole time, just forgot about it.

When you open your new workbook and you get the message to update links, click on that and then when you get the answer back that some links
could not be updated, click on "edit" and you will get a box opening up to change the "source". Update with your new workbook name and that's it!

Thanks to all who took the time to read, and to Micron for responding!
 
Upvote 0
Solution
I never know when to question "why" to posted code when there are other ways. This time I didn't and should have. I was wondering why you just couldn't update the links, thinking users were fed up with doing that manually.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top