Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Goto "Start of Sub"

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Goto "Start of Sub"

Hi Bob.

Thanks!

I have code that check the input in the txtbox on the userform, and return
that to a range in the sheet, but if the input in the txtbox is out of range
(ex. less than 0) a msgbox emerge and tell the user its out of range. I want
to use a error handler in the code that "start again". My point is; if the
input is out of range and the user click Ok on the msgbox he will get a
second chance.


--
Nil Satis Nisi Optimum


"Bob Phillips" wrote:

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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Goto "Start of Sub"

Michael,

I would still use a button with code like

Private Sub CommandButton1_Click()
Dim ans
With Me.TextBox1
If CDbl(.Text) < 0 Then
ans = MsgBox("Invalid Amount, try again", vbOKCancel)
If ans = vbOK Then
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
Else
Worksheets("Sheet1").Range("A1").Value = .Text
End If
End With
End Sub

--

HTH

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


"Michael" wrote in message
...
Hi Bob.

Thanks!

I have code that check the input in the txtbox on the userform, and return
that to a range in the sheet, but if the input in the txtbox is out of

range
(ex. less than 0) a msgbox emerge and tell the user its out of range. I

want
to use a error handler in the code that "start again". My point is; if the
input is out of range and the user click Ok on the msgbox he will get a
second chance.


--
Nil Satis Nisi Optimum


"Bob Phillips" wrote:

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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get cursor to start with "Find What i/o "Repalce With"? eatong Excel Discussion (Misc queries) 1 May 28th 09 04:07 PM
set up macro to goto cell with "today" in Stuart WJG Excel Worksheet Functions 7 March 13th 08 03:19 PM
HOW IS COLUMN "K" REFERENCED ON THE CURRENT ROW IN THE GOTO COMMAN mbnspect Excel Discussion (Misc queries) 5 January 10th 08 11:50 PM
Question on "On Error GoTo skip" dan Excel Discussion (Misc queries) 2 July 1st 07 10:48 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"