Copying button and event

jcg31

Board Regular
Joined
Aug 20, 2006
Messages
176
I have a button with a click event that I want to copy across a number of worksheets that are created during runtime. How does one copy and paste an object and retain the code behind in the paste?

Thanks,
Jim
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Sounds like you are using a Controls Toolbox button. You will have to re-build the click event code with each copy you do.

The easy solution would be to use a Forms button. Then the code copies with the button.
-or-
If you don't like the drab look of the Forms button, you can use a Drawing Toolbar Shape (I like the Bevel shape), and assign it to a macro. You can add color, shadow, etc. as desired. When you copy it, all the properties, including the code, copy with it just like a Forms button.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

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