Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Jumping out of loop with GoTo function

Hi people!

I would like to jump out of a Do loop using the goto statement e.g.

Do Until condition

While i= 0 And i < value

if value = 1

GoTo Line1:

End If

Wend

Loop

Line1:

Obviously this doesn't do anything, but is the structure correct and
the code correct for the statements shown? Do I need to declare Dim
Line1 as String. My program doesn't work and I think GoTo has something
to do with it not working. I do not have the help file either.

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Jumping out of loop with GoTo function

If value = 1 Then 'Forgot the "Then"
GoTo Line1 'No colon needed here

HTH

Charles

Andy wrote:
Hi people!

I would like to jump out of a Do loop using the goto statement e.g.

Do Until condition

While i= 0 And i < value

if value = 1

GoTo Line1:

End If

Wend

Loop

Line1:

Obviously this doesn't do anything, but is the structure correct and
the code correct for the statements shown? Do I need to declare Dim
Line1 as String. My program doesn't work and I think GoTo has something
to do with it not working. I do not have the help file either.

Thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Jumping out of loop with GoTo function

Hi Andy
If Line1: would be the next statement after Loop, you can use

....
if value = 1 then
Exit Do
End If
Wend
Loop
'goes here if value = 1
.....

Avoid using Goto whenever possible, which is almost always. The only
place it is still needed is "On Error Goto...."

Len

Andy wrote:
Hi people!

I would like to jump out of a Do loop using the goto statement e.g.

Do Until condition

While i= 0 And i < value

if value = 1

GoTo Line1:

End If

Wend

Loop

Line1:

Obviously this doesn't do anything, but is the structure correct and
the code correct for the statements shown? Do I need to declare Dim
Line1 as String. My program doesn't work and I think GoTo has something
to do with it not working. I do not have the help file either.

Thank you

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
Jumping in a For ..Next Loop Bertrand Excel Programming 1 July 21st 06 07:33 PM
On Error GoTo Label in a loop only working once. Ken Johnson Charts and Charting in Excel 4 July 5th 06 09:39 PM
goto function Ray Excel Programming 22 August 7th 05 11:52 PM
GOTO Using the ()NOW Function Q John[_78_] Excel Programming 3 November 7th 04 09:01 PM
GoTo Loop? JayL Excel Programming 3 May 18th 04 02:00 PM


All times are GMT +1. The time now is 06:57 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"