Using a commandbutton to start a macro

sfalk

New Member
Joined
Nov 6, 2002
Messages
37
My job requires me to do a lot of copying of data that is a standard and then pasting it into another sheet of my workbook. We are lookint to streamline this using a macro that will automatically go to the desired sheet, select data, copy it, then return to the main sheet. I would like to use a button on the sheet to perform this function instead of Crtl-?. I do not know what code to write.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Im not too sure what you mean. Do you just need to know how to insert a command button? If not could you be more clear.

1. On the control toolbox clik on the design view button.
2. Click on the command button icon and draw the button on to the sheet.
3. Right click the button (still in design mode) and clickon view code. You can insert the code you need in to the sub.
$. Exit design mode.
 
Upvote 0
Post a sample of your data and specify:

1. What needs to be copied (including any conditions that need to be applied) and

2. The name of the target sheet and where the data is to be pasted.
 
Upvote 0
I know how to create a commandbutton, I do not know how to write the code to run a macro. What I was doing was trying to follow VB help and it is a bit to technical for me at this time. I thought all I had to do was type

Run (Column_copy)

Column_copy is the name of my macro and the keys to run it are
Crtl-n
 
Upvote 0
What I am trying to copy are a specific group of cells that contain generic data from a sheet titles "Calculator". This data need to be pasted into a sheet titled
"Master" I take the data that I pasted and then enter various weights and hours to come up with a price for performing various construction activities. I wrote a macro to perform this task and called it "Column_copy". I want to just put a button next to the data in the "Calculator" section so that all I have to do is click on it and it will automatically complete the macro.
 
Upvote 0
Hi;

just write the name of your macro to be run, i.e;

Private Sub CommandButton1_Click()
Column_copy
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,403
Messages
6,119,309
Members
448,886
Latest member
GBCTeacher

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