UserForm Activation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When showing a UserForm, I tried to use this code:

Private Sub UserForm1_Activate()
MsgBox "hello"
Place code here that or call another sub rotine from here
End Sub

The UserForm opens up, but the Msgbox does not appear. What am I doing wrong? Thank you.

Doug
 
Have you put the code in the userform code module (not a normal code
module)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob,

No. Do I have to rename the Module to be the same name as the UserForm? Can you direct me to a link where I might be able to read up on this a little? Sorry to be such a dunce. I am trying to learn this as I go along, which is not always the best way. Thank you.

DOug
 
Try adding brackets ie:

MsgBox ("text")

-----Original Message-----
Bob,

No. Do I have to rename the Module to be the same name
as the UserForm? Can you direct me to a link where I
might be able to read up on this a little? Sorry to be
such a dunce. I am trying to learn this as I go along,
which is not always the best way. Thank you.
 
Doug,

You don't put this code in standard code modules. It goes in the
code module associated with the user form. Right-click the form
and choose View Code. Place the code in that module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


Doug said:
Bob,

No. Do I have to rename the Module to be the same name as the
UserForm? Can you direct me to a link where I might be able to
read up on this a little? Sorry to be such a dunce. I am trying
to learn this as I go along, which is not always the best way.
Thank you.
 
Chip,

Thank you. I now understand what you mean. But the code goes in the Activate section that gets called when the userform first opens up, correct?

Thanks.

Doug
 
Doug,

Yes that is one place it can go.

It can be put in the Initialize section that is invoked when the for is
loaded into memory, the Activate section when the form is displayed, or it
could be driven by any number of other events, such as clicking a button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Doug said:
Chip,

Thank you. I now understand what you mean. But the code goes in the
Activate section that gets called when the userform first opens up, correct?
 
Back
Top