Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
I have a userform with a commandbutton1.
I have recorded a macro which I would to run it when commandbutton1 is pressed. -- Tdp |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Hi
Copy the desired code without Sub... / End Sub statements. Select your userform in the VBA editor and right click on commandButton1, select "view code". The code window for your userform will show: Private Sub CommandButton1_Click() End Sub Paste your code between theese two lines. Regards, Per "Tdp" skrev i meddelelsen ... I have a userform with a commandbutton1. I have recorded a macro which I would to run it when commandbutton1 is pressed. -- Tdp |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Double click on the button and copy the recorded macro into it Cheers "Tdp" wrote: I have a userform with a commandbutton1. I have recorded a macro which I would to run it when commandbutton1 is pressed. -- Tdp |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Sorry guys,
Its the other way round I'm after. I have the code in the userform but I wish to move the code to a module, name it macro1 and then in the userform code under commandbutton1 I want to write a code to run macro1. -- Tdp "Per Jessen" wrote: Hi Copy the desired code without Sub... / End Sub statements. Select your userform in the VBA editor and right click on commandButton1, select "view code". The code window for your userform will show: Private Sub CommandButton1_Click() End Sub Paste your code between theese two lines. Regards, Per "Tdp" skrev i meddelelsen ... I have a userform with a commandbutton1. I have recorded a macro which I would to run it when commandbutton1 is pressed. -- Tdp |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Make sure Sub in Userform is not private..
Userform.UserformProcedurename i.e. In Sheet Code.. Sub CommandButton1_Click() MyForm.FormCommandButton1_Click End Sub in Myform... Sub FormCommandButton1_Click ' Do stuff... End Sub Hope Its of use.. A "Tdp" wrote in message ... | Sorry guys, | Its the other way round I'm after. | I have the code in the userform but I wish to move the code to a module, | name it macro1 and then in the userform code under commandbutton1 I want to | write a code to run macro1. | -- | Tdp | | | "Per Jessen" wrote: | | Hi | | Copy the desired code without Sub... / End Sub statements. | | Select your userform in the VBA editor and right click on commandButton1, | select "view code". The code window for your userform will show: | | Private Sub CommandButton1_Click() | | End Sub | | Paste your code between theese two lines. | | Regards, | Per | | | "Tdp" skrev i meddelelsen | ... | I have a userform with a commandbutton1. | I have recorded a macro which I would to run it when commandbutton1 is | pressed. | -- | Tdp | | |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Hi Andrew,
is the second code to be placed in a module? -- Tdp "Andrew" wrote: Make sure Sub in Userform is not private.. Userform.UserformProcedurename i.e. In Sheet Code.. Sub CommandButton1_Click() MyForm.FormCommandButton1_Click End Sub in Myform... Sub FormCommandButton1_Click ' Do stuff... End Sub Hope Its of use.. A "Tdp" wrote in message ... | Sorry guys, | Its the other way round I'm after. | I have the code in the userform but I wish to move the code to a module, | name it macro1 and then in the userform code under commandbutton1 I want to | write a code to run macro1. | -- | Tdp | | | "Per Jessen" wrote: | | Hi | | Copy the desired code without Sub... / End Sub statements. | | Select your userform in the VBA editor and right click on commandButton1, | select "view code". The code window for your userform will show: | | Private Sub CommandButton1_Click() | | End Sub | | Paste your code between theese two lines. | | Regards, | Per | | | "Tdp" skrev i meddelelsen | ... | I have a userform with a commandbutton1. | I have recorded a macro which I would to run it when commandbutton1 is | pressed. | -- | Tdp | | |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
If you open the Form in VB Editor,
Right click - And... View Code - Put code in there.. Can be accessed from a module or from the Sheets' Code by Prefixing with the form name. If you use the project explorer Sub window in Vb Editor- (Ctrl+R) or View..Project Explorer you will see your project and all parts of it (Workbook, Worksheets , Forms and Modules). In VB Editor - I Personally use this docked on the Left, and the properties window Docked on the right. Don't hesitate to ask if you need anymore help. A. "Tdp" wrote in message ... | Hi Andrew, | is the second code to be placed in a module? | -- | Tdp | | | "Andrew" wrote: | | Make sure Sub in Userform is not private.. | | Userform.UserformProcedurename | i.e. | In Sheet Code.. | Sub CommandButton1_Click() | MyForm.FormCommandButton1_Click | End Sub | | in Myform... | Sub FormCommandButton1_Click | ' Do stuff... | End Sub | | Hope Its of use.. | A |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Hi,
If the sub routine MyMacro is in a regular module and is not Private, that means its name is Sub MyMacro() not Private Sub MyMacro() Then the code attached to CommandButton1 in your user form is simpy Private Sub CommandButton1_Click() myMacro End Sub -- Thanks, Shane Devenshire "Tdp" wrote: I have a userform with a commandbutton1. I have recorded a macro which I would to run it when commandbutton1 is pressed. -- Tdp |
#9
Posted to microsoft.public.excel.misc
|
|||
|
|||
VB code to run macro?
Is that not what i said..? In previous - Sun 02 November
2008 13:00pm A. "ShaneDevenshire" wrote in message ... | Hi, | | If the sub routine MyMacro is in a regular module and is not Private, that | means its name is | | Sub MyMacro() | | not | | Private Sub MyMacro() | | Then the code attached to CommandButton1 in your user form is simpy | | Private Sub CommandButton1_Click() | myMacro | End Sub | | | -- | Thanks, | Shane Devenshire | | | "Tdp" wrote: | | I have a userform with a commandbutton1. | I have recorded a macro which I would to run it when commandbutton1 is | pressed. | -- | Tdp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA code for macro help | Excel Discussion (Misc queries) | |||
Deleting code from a macro (by a macro) | Excel Discussion (Misc queries) | |||
Macro code | Excel Discussion (Misc queries) | |||
Help With Macro Code?? | Excel Worksheet Functions | |||
Zip Code Macro | Excel Worksheet Functions |