PC Review


Reply
Thread Tools Rate Thread

Call a Control_Click Event when UserForm is Initialized

 
 
RyanH
Guest
Posts: n/a
 
      27th Dec 2007
I have a UserForm with several CheckBoxes, TextBoxes, ComboBoxes, etc. I
also have a Command Button Click Event that calculates totals of everything.
I have the Controls in the UserForm autofilled by a worksheet and then call
the Userform. For example:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

''''code to autofill userform

UserForm.Show
End Sub

I want to insert some code to automatically call the commandbutton_click
event so all my totals will automatically be there and the user does not have
to click the command button, how do I do this?

Thanks for your help in advance!!

 
Reply With Quote
 
 
 
 
sebastienm
Guest
Posts: n/a
 
      27th Dec 2007
Hi,
I suppose you fill controls in the form in the _Initialize event.
Move this code in a new sub of the Userfomr:
Public Sub FillForm( )
and in _Initialize, just call FillFOrm
Also, move the code that calculates the form out of the _Click event:
Public Sub Calculate()
and in _Click, just call Calculate

Now to show the form:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
USeform.FillForm
Userform.Calculate
UserForm.Show
End Sub


--
Regards,
Sébastien
<http://www.ondemandanalysis.com>
<http://www.ready-reports.com>


"RyanH" wrote:

> I have a UserForm with several CheckBoxes, TextBoxes, ComboBoxes, etc. I
> also have a Command Button Click Event that calculates totals of everything.
> I have the Controls in the UserForm autofilled by a worksheet and then call
> the Userform. For example:
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
>
> ''''code to autofill userform
>
> UserForm.Show
> End Sub
>
> I want to insert some code to automatically call the commandbutton_click
> event so all my totals will automatically be there and the user does not have
> to click the command button, how do I do this?
>
> Thanks for your help in advance!!
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking a userForm that has not been initialized =?Utf-8?B?QXJuZSBIZWdlZm9ycw==?= Microsoft Excel Programming 4 2nd Aug 2006 02:44 PM
How does Userform get initialized by this? RB Smissaert Microsoft Excel Programming 4 12th Nov 2005 05:44 PM
Add ValueChanged event handler AFTER control is initialized =?Utf-8?B?SmF2YW1hbjU5?= Microsoft C# .NET 2 19th Aug 2005 03:57 AM
Userform runs other subs when initialized zipdog Microsoft Excel Programming 3 2nd Feb 2005 04:04 PM
Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded? Luisa Microsoft Excel Programming 2 5th Dec 2003 08:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:58 PM.