Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default How to execute a CommandButton_Click macro without clicking on

Hi,
The Userform2 is opened from a Userform1 click. So, at the execution of the
CommandButton1, after UserForm2.Show line, I'm wondering if it's possible to
execute the macro inside CommandButton2_Click as if the user clicked on.
Thanks!!
Alex
Private Sub CommandButton1_Click()
UserForm1.Hide
Load UserForm2
UserForm2.CommandButton2.BackColor = RGB(166, 182, 214)
UserForm2.CommandButton2.SetFocus
'Something like Userform2.Browse.ExecuteMacro ??
UserForm2.Show
End Sub
--
Alex St-Pierre
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default How to execute a CommandButton_Click macro without clicking on

Hi
Commandbutton2 must call a macro, so simply do

Call myMacro

Your Commandbutton2_Click macro would be

Private sub Commandbutton2_Click ()
Call myMacro
End sub

and myMacro would be in a normal code module (cut and paste your
existing code out of Commandbutton2_Click ).
regards
Paul

On Mar 22, 6:23 pm, Alex St-Pierre
wrote:
Hi,
The Userform2 is opened from a Userform1 click. So, at the execution of the
CommandButton1, after UserForm2.Show line, I'm wondering if it's possible to
execute the macro inside CommandButton2_Click as if the user clicked on.
Thanks!!
Alex
Private Sub CommandButton1_Click()
UserForm1.Hide
Load UserForm2
UserForm2.CommandButton2.BackColor = RGB(166, 182, 214)
UserForm2.CommandButton2.SetFocus
'Something like Userform2.Browse.ExecuteMacro ??
UserForm2.Show
End Sub
--
Alex St-Pierre



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default How to execute a CommandButton_Click macro without clicking on

Do:

Public Sub CommandButton1_Click()

Then you can do:

UserForm2.CommandButton1_Click

RBS


"Alex St-Pierre" wrote in message
...
Hi,
The Userform2 is opened from a Userform1 click. So, at the execution of
the
CommandButton1, after UserForm2.Show line, I'm wondering if it's possible
to
execute the macro inside CommandButton2_Click as if the user clicked on.
Thanks!!
Alex
Private Sub CommandButton1_Click()
UserForm1.Hide
Load UserForm2
UserForm2.CommandButton2.BackColor = RGB(166, 182, 214)
UserForm2.CommandButton2.SetFocus
'Something like Userform2.Browse.ExecuteMacro ??
UserForm2.Show
End Sub
--
Alex St-Pierre


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default How to execute a CommandButton_Click macro without clicking on

Cool
I knew public variables in form code are properties of the form, but
this never occured to me.
Paul

On Mar 22, 6:50 pm, "RB Smissaert"
wrote:
Do:

Public Sub CommandButton1_Click()

Then you can do:

UserForm2.CommandButton1_Click


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default How to execute a CommandButton_Click macro without clicking on

Since you're displaying UserForm2 as a modal dialog, you can call the
commandbutton2_click subroutine in the Activate event of Userform2. So, in
UserForm2 code module:

Private Sub UserForm_Activate()
CommandButton2_Click
End Sub



--
Hope that helps.

Vergel Adriano


"Alex St-Pierre" wrote:

Hi,
The Userform2 is opened from a Userform1 click. So, at the execution of the
CommandButton1, after UserForm2.Show line, I'm wondering if it's possible to
execute the macro inside CommandButton2_Click as if the user clicked on.
Thanks!!
Alex
Private Sub CommandButton1_Click()
UserForm1.Hide
Load UserForm2
UserForm2.CommandButton2.BackColor = RGB(166, 182, 214)
UserForm2.CommandButton2.SetFocus
'Something like Userform2.Browse.ExecuteMacro ??
UserForm2.Show
End Sub
--
Alex St-Pierre



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use VB code to execute macro when double-clicking cell? JDay01 Excel Programming 2 June 13th 06 03:12 PM
How do i execute a VBA function by clicking on an excel cell? Matthew Excel Discussion (Misc queries) 1 December 7th 05 01:10 AM
commandbutton_click problem Daniel R. Young Excel Programming 9 September 9th 05 04:28 AM
Clicking on a cell to execute a routine Mark Excel Programming 2 January 27th 04 12:20 PM
Userform - CommandButton_Click question Tommy Flynn Excel Programming 1 September 8th 03 04:12 PM


All times are GMT +1. The time now is 05:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"