View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default Basic UserForm question - please help

Not sure what you mean by wanting the form to stay up
while th e rest of the code runs...

I'll take a guess that your procedure is

....code1
userform1.Show
....code2

and you want code2 to run while the form is displayed.
This is a function of the MODAL state. By default, the
userform.Show method is modal
This means that code execution waits for the form to
close before continuing with code2. Force the form to
open in modeless state then code will continue event
while the form is showing

....code1
userform1.Show vbModeless
....code2

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Please help if you can. In my Excel macro, Sheet 1

determines if value 1 is greater than value 2 and if so,
calls UserForm1. UserForm1 is a simple form, with some
text and an OK button. Clicking the OK button closes the
UserForm. So far, so good. When UserForm1 opens up, I
need it to stay on the screen until a user clicks the OK
button. While it is up, I need the rest of the macro to
function. If I highlight UserForm1 and view code, I get
my code:

Private Sub UserForm1_Activate()
MsgBox "This is a test - hello"
'Place code here that or call another sub rotine from

here
End Sub

Problem is, this refuses to show me the message box.

What I am doing wrong? Why won't the UserForm1_Activate()
work?

Doug
.