Thread: VBA go to line
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default VBA go to line

Sub TryNow()
Dim Test As Boolean
Dim This As Integer
Dim That As Integer

This = 1
That = 1

Test = MsgBox("Continue?", vbYesNo) = vbYes

If Test = True Then GoTo L1
Exit Sub

L1:
While This = That
MsgBox "I'm in the loop"
This = InputBox("Give me a number: 1 to continue, other to stop")
Wend

MsgBox "I've stopped"

End Sub

HTH,
Bernie
MS Excel MVP


"Jeff" wrote in message
...
Hi,

I have some code and a while loop. I want to go to the line where the text
"L1" is in the code. "L1" is right before the while loop. and I want to go
to the "L1" based on the result of an if statement.

I was looking for a "Go to" function in my VBA manual, but I could not find
anything.

Is there a Go to function that can help me?

Thanks for your help