Add a button and macro from one worksheet to another

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have a very useful button I use on a worksheet to paste data. I want to copy this button (and it's macro) to another sheet. Is this possible? If so. how do I go about it?

Thank You, :eek:
Michael
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Go into design mode (green triangle icon on the toolbar)
Right-click the button, "copy".

Go to the other sheet, right click and "Paste"

That'll do the button bit......... Is the button from a "Forms" button or a "Command" button?
 
Upvote 0
It is just a button floating on a spreadsheet. I got it from...... the forms toolbar.

Thank You,
michael
 
Upvote 0
Ok Michael

Assuming the other bit worked, you've now got a copy on your other sheet.

If the button's a "Forms" one, the macro should copy accross automatically. If not........

On the original button, right click, select "Assign Macro" and see the name of the macro already assigned (should be in the top dropdown box.)
Now do the same with the new Button, selecting the same Macro from the dropdown.
 
Upvote 0
Maybe the easiest way is something like this :

Code:
Sub Button1_Click()
    MsgBox "Test"
End Sub


Sub Button2_Click()
    Button1_Click
End Sub

Where Button1 is the initial button and Button2 is the copied one.


Regards.
 
Upvote 0
Isn't the green triangle design mode for Microsoft Access? Can't find it!!


Michael :oops:
 
Upvote 0
Up the top - View / Toolbars / Visual Basic
 
Upvote 0
The button is actually in a sheet. I need to copy it to another sheet. It goes with the spreadsheet, it does not stay in a toolbar. Hope this clears up what I want to do.

I can create a button on a sheet. That is easy. I need to know how to either copy the code behind it, with it or copy and paste the code. If I copy and paste the code, where to put it???


Michael
 
Upvote 0
I'm perfectly aware that your button is not attached to a toolbar.

My previous post was to answer your question of where to find the "Green Triangle" i.e. design mode button.
My suggested actions will bring up the Visual basic toolbar, which normally contains the design mode button.

Going in to design mode will then allow you to right click your buttons and access the code behind the button in order to copy it.

But, as I've already stated, if your button is, indeed a Forms button, then the code should automatically follow it accross when you copy and paste the button, and you shouldn't even need to go into design mode for that.
 
Upvote 0
I am so sorry for being ignorant.
I could not find a triangle. I right click on a toolbar and hit customize. I then found a triangle under control toolbox. I then added it to my standard toolbar. I then copied and pasted as you suggested and it works great.
Thank You,
Michael :pray:
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,264
Members
448,558
Latest member
aivin

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