View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Goto "Start of Sub"

Michael,

I think you are getting a bit confused on how objects work.

A textbox is an object, and there are various events associated with it. You
can only hand control to your code by trapping one of these events. Once you
have completed your action (reaction) to the event), you exit and your code
hands back to the system that will allow any other object on the userform to
be acted upon.

So what I am saying is you should either test on the textbox exit if it is
empty and then force the user back in, or (preferably IMO), have some sort
of commit button (usually called OK) which when clicked you check that all
is okay. If so, don't let them finish, but force them back to the error. And
of course you have a Quit button so that they can quit complete or not.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael" wrote in message
...
Hi.

I have a button on my excel sheet that call a macro (sub).

Both in the middle and in the end of the sub a userform emerge where the
user can choose if he want to continue or start at the beginning of the

sub.

My question is: Is there a command (code) (like Goto??) to go back to the
beginning of the sub?

How should i write a code that check if a txtbox on a userform is empty,

and
if it is a msgbox emerge. If the user click OK on the msgbox he will get

a
second (or more) chance to write in the txtbox!

Any suggestion?

--
Nil Satis Nisi Optimum