Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default GoTo won't work - why?

In a sub

TryAgain:

(some code)

Application.GoTo TryAgain

(more code)

End Sub

I never use GoTo statements except for error handling so I wonder if they
will backup as well as skipping lines? I really need this thing to back up.
When running, the Application.Goto TryAgain line is skipped as if it isn't
there. Not even an error. What's up?

Thanks for any help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default GoTo won't work - why?

It will not stop at the label, but should execute the first line after the
label.

TryAgain:

MsgBox "This line executes
'More code
Application.GoTo TryAgain:


"Jim" wrote:

In a sub

TryAgain:

(some code)

Application.GoTo TryAgain

(more code)

End Sub

I never use GoTo statements except for error handling so I wonder if they
will backup as well as skipping lines? I really need this thing to back up.
When running, the Application.Goto TryAgain line is skipped as if it isn't
there. Not even an error. What's up?

Thanks for any help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default GoTo won't work - why?

I fixed it. I changed Application.Goto TryAgain to just Goto TryAgain but
this didn't work either. I closed Excel and restarted it. Now it works.

"Jim" wrote in message
...
In a sub

TryAgain:

(some code)

Application.GoTo TryAgain

(more code)

End Sub

I never use GoTo statements except for error handling so I wonder if they
will backup as well as skipping lines? I really need this thing to back
up. When running, the Application.Goto TryAgain line is skipped as if it
isn't there. Not even an error. What's up?

Thanks for any help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default GoTo won't work - why?


I fixed it. I changed Application.Goto TryAgain to just Goto TryAgain


Goto and Application.Goto are completely unrelated. Application.Goto
scrolls to and display a location on a worksheet. VBA's GoTo moves the
execution point in code.

Just as an aside, I would try to eliminate the need for a Goto
statement and make your code more structured and modular. Goto is
universally considered a very poor coding practice by professional
developers. One or two Gotos may be harmless, but code with lots of
Goto jumps make debugging, maintenance, and expansion quite difficult.
You don't want to get in the habit of using Gotos. They are bad news.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 28 Feb 2009 22:43:45 -0600, "Jim"
wrote:

I fixed it. I changed Application.Goto TryAgain to just Goto TryAgain but
this didn't work either. I closed Excel and restarted it. Now it works.

"Jim" wrote in message
.. .
In a sub

TryAgain:

(some code)

Application.GoTo TryAgain

(more code)

End Sub

I never use GoTo statements except for error handling so I wonder if they
will backup as well as skipping lines? I really need this thing to back
up. When running, the Application.Goto TryAgain line is skipped as if it
isn't there. Not even an error. What's up?

Thanks for any help.


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
On Error GoTo Doesn't Work [email protected] Excel Discussion (Misc queries) 2 November 29th 07 09:43 PM
On Error GoTo Doesn't Work [email protected] Excel Programming 1 November 29th 07 09:22 PM
Goto alvin Kuiper Excel Programming 5 August 6th 07 12:46 PM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM


All times are GMT +1. The time now is 12:54 AM.

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"