title: Excel vba refresh wait
body: <p>I am creating some code where I can click on a single button and it will refresh the querytables that I have on that sheet.</p>
  
  <p>Now, my problem is that I have more code after the fresh that copies some of the information, but this code is being run right after the refresh has started and the information has not yet been replaced.</p>
  
  <p>I want to create a waiting period for the refresh to complete and then the rest of the code can continue.</p>
  
  <p>I don't want to just wait for 5 seconds but for the refreshing period, so that I am not waiting too long or too short, depending on Internet speed etc.</p>
  
  <p>How can I do this? </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Simple code:</p>
  
  <pre><code>ActiveWorkbook.RefreshAll
  </code></pre>
  
  <p>Here I need the delay or waiting code till all the refreshing is finished... Then</p>
  
  <pre><code>MsgBox("The Refreshing is Completed!")
  </code></pre>
  
  <p>Something in that direction. But it can't say the msgbox before it is actually finished.... Sometimes depending on internet speed the refreshing takes shorter or longer, so I want it to be a variable of the actual refreshing time. </p>