MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds


  Asked By: Bill    Date: Nov 24    Category: MS Office    Views: 1563

I have this segment of code in my spreadsheet to load my
userform in the middle of a lot of other code. The end is there because
this is in a if statement in the middle of the code.

'Inserts a userform to wait for T1T1 data to be entered for new cells

Load pauseform

pauseform.Show 0


The problem is that the userform does not load before the program ends.
It's as if the code is running faster than the application can computer
and so it just ends. Any ideas?



4 Answers Found

Answer #1    Answered By: Freddie Evans     Answered On: Nov 24

Try putting a DoEvents in before the End

Not saying it will work but it's worth a shot.

DoEvents clears all waiting Events before going on...

Let us know if it works.

Answer #2    Answered By: Jonah Brown     Answered On: Nov 24

"End" will end  everything. What are you actually wanting to end?

"End If" needs the keyword "If"

"Exit Sub" or "Exit Function" to exit a sub or a function


Post more of the code  and tell us what is actually supposed to happen where
you have your "End" statement.

Also, have you compiled the project to make sure it has no syntax errors in

Answer #3    Answered By: Boyce Fischer     Answered On: Nov 24

The code  runs fine and at the end  I do want to end everything. However
I would like the userform  to load  before the code ends. That is the
only real problem. Also, I have run the code a few times. It works
great except the form no longer loading. (It loaded before I used the
end function and just put a break in the code manually.)

Answer #4    Answered By: Stacy Cunningham     Answered On: Nov 24

AFAIK, "end" ends everything, including user forms. So the form is probably
loading, and then getting "ended".

You don't want to "end" until you are really finished (i.e. about to close
the workbook). In fact, you shouldn't even want to do it then. Only use
"end" as an "emergency shutdown" if there is a fatal error, and processing
must not continue.

Just return from whatever subroutines you are in (using Exit Sub if you
can't just return normally). The form will then be left showing and VBA
will be waiting for the next user event.

BTW I don't know what you're expecting to do with a form called pauseform,
but I suspect you won't achieve it. Excel programs are event-driven and
there is no concept such as a "pause".

Didn't find what you were looking for? Find more on sequencing Or get search suggestion and latest updates.