ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA go to line (https://www.excelbanter.com/excel-discussion-misc-queries/58198-vba-go-line.html)

Jeff

VBA go to line
 
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

Bernie Deitrick

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





All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com