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
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,759
Office Version
  1. 365
Platform
  1. Windows
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?
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
It is just a button floating on a spreadsheet. I got it from...... the forms toolbar.

Thank You,
michael
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,759
Office Version
  1. 365
Platform
  1. Windows
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.
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,060
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

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.
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Isn't the green triangle design mode for Microsoft Access? Can't find it!!


Michael :oops:
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,759
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Up the top - View / Toolbars / Visual Basic
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
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
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,759
Office Version
  1. 365
Platform
  1. Windows
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.
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
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:
 

Watch MrExcel Video

Forum statistics

Threads
1,118,068
Messages
5,570,003
Members
412,304
Latest member
citrus
Top