I'm trying to write a code that will automatically refresh a website every 10 minutes. I have a Start and Stop button. Once the start button is clicked, the refreshing will start. The problem is I can't click the Stop button because a code is running.

Here is my code:

Public Sub Start()

    wksMain.Range("A5").Value = "start"

x:
    VBA.DoEvents

    If wksMain.Range("A5").Value = "stop" Then Exit Sub

        AppActivate "Kampala - Wikipedia"
        SendKeys "{F5}"
        Application.Wait (Now + TimeValue("00:10:00"))

    GoTo x

End Sub

Public Sub Stopper()
    wksMain.Range("A5").Value = "stop"
End Sub

0 Answers