title: How to break and restart code execution automatically in VBA? Error-Handling
body: <p>I wrote a code to scrape web information from Google Patents in VBA which works pretty well but unfortunately it is pretty susceptible to two errors. </p>
  
  <p>The two most common are </p>
  
  <ul>
  <li>runtime error</li>
  <li>Windows OLE is waiting for ...</li>
  </ul>
  
  <p>All that needs to happen when this occurs is just press ok, ctrl break, F5 and execute again. Also for reasons unknown to me the code seems to slow down after x minutes and then breaking and restarting it accelerates the speed.</p>
  
  <p>So as a patch-all solution I'd like to do the following. After x minutes (or even better after let's say 40 iterations), automatically break the execution and start again. 
  A second error-handling way which would be great is do something like</p>
  
  <p><code>If Range("A1".End(xlDown)) at time t = Range("A1".End(xlDown)) at time t + 600 Then restart code execution Else continue code execution</code> </p>
  
  <p>I'm basically hoping to automate my error handling so that I can run the code overnight and sleep like a baby :)</p>