samedi 11 août 2018

Is there a way to skip to a certain line in VBA

I am looking to find a way to skip to or goto the end if certain condition is not met. I'm just learning VBA code for a home project, very new at this. Here is what I have.

Sub Macro1()

    ' Some stuff here

    Sheets("Sheet1").Select
    ActiveWorkbook.RefreshAll

    If Sheets("Sheet1").Range("A8") <> "" Then
         GoTo Line122
    Else
        ' Do all this if the condition is false
    End If

    ' There is more in between

    ' I want to skip to here
    Call Test

End Sub

Sub Test()

    Application.OnTime Now + TimeValue("00:08:00"), "Macro1"

End Sub

If Cell A8 is blank I want to wait 8 min then start Macro1 with refresh. How can I skip the rest part of code after condition check and continue directly from the line Call Test?

Aucun commentaire:

Enregistrer un commentaire