View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Tdp Tdp is offline
external usenet poster
 
Posts: 74
Default 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
|
|