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.
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

k209310

Active Member
Joined
Aug 12, 2002
Messages
382
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.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

sfalk

New Member
Joined
Nov 6, 2002
Messages
37
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
 

sfalk

New Member
Joined
Nov 6, 2002
Messages
37

ADVERTISEMENT

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.
 

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
Hi;

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

Private Sub CommandButton1_Click()
Column_copy
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,216
Messages
5,594,885
Members
413,947
Latest member
gizmolucy

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
Top